Pages

Google Analytics Alternative

Search This Blog

Loading...

Wednesday, April 3, 2013

How to get div whose id start with “panel” from page body using jquery

Query : How to get div whose id start with “panel” from page body using jquery.
solution : $('div[id^="panel_"]')
the above jquery script will return you list of div whose id start with “panel”.

Thursday, October 25, 2012

EntityFramework inner join

Column concatenation using Linq to EntityFramework.
here we have one simple example where there are two tables.
one
Employee with following fileds

CREATE TABLE [dbo].[empMaster](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Age] [int] NULL,
[IsActive] [bit] NULL CONSTRAINT [DF_empMaster_IsActive]  DEFAULT ((1)),
[CreatedDate] [datetime] NULL CONSTRAINT [DF_empMaster_CreatedDate]  DEFAULT (getdate()),
 CONSTRAINT [PK_empMaster] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]


and another table is with

CREATE TABLE [dbo].[employee](
[id] [int] IDENTITY(1,1) NOT NULL,
[Salary] [int] NULL,
 CONSTRAINT [PK_employee] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]







Now i want to get name of employee and salary of that employee.
so i used innerjoin like this

select em.id,em.name,e.salary
from empMaster em
inner join employee e
on em.id=e.id
Result of inner join.


but in Linq To EntityFrame work it works like this.

   var outputvalue = (from emp in obj.empMasters 
                                      join e in obj.employees on emp.Id equals e.id
                                     select new {
                                        emp.Name,e.Salary,emp.Id  
                                     }).ToList().Select(q =>new {Id = q.Id,Name = q.Name,dummyValue = q.Id.ToString() + " " + 
                                         q.Name.ToString()});

Thanks



Tuesday, October 16, 2012

Prepare DTO layer by using below script


DECLARE @CurID INT, @MaxID INT
Declare @sql nvarchar(MAX)
Declare @TmpTable table (ID int Identity(1,1), c_Column_name varchar(500),c_Data_type varchar(50),c_character_Maximum_length nvarchar(50))

Insert into @TmpTable (c_Column_name,c_Data_type,c_character_Maximum_length)
    SELECT COLUMN_NAME ,DATA_TYPE ,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'TT_M_User'  --Table Name
ORDER BY ORDINAL_POSITION ASC;
set @CurID = 1
set @sql=''
SELECT @MaxID=Max(ID) FROM @TmpTable WHILE @MaxID >=@CurID BEGIN -- Logic to be performed
select @sql = @sql + char(13)+ ' public ' +
    case c_Data_type
    when 'varchar' then ' string '
    when 'nvarchar' then ' string '
    when 'bit' then ' bool '
    when 'datetime' then ' DateTime '
    when 'binary' then ' Byte[] '
    else c_Data_type end + ' ' + c_Column_Name + ' {get;set;} '
from @TmpTable where ID=@CurID
set @CurID = @CurID +1
END
print @sql

Thursday, May 24, 2012

Find job by jobberclub

Now it is too easy to find job for freshers to experts.

just visit this below link now. and search your desire profile job.

http://www.jobberclub.com/search/

I hope it will help you.
thanks

Tuesday, May 1, 2012

Three simple character that is important in every once life.
G : Generator
O : Operator
D : Destroyer

God is Generator of life.
God is Operator of life.
and finally
God is Destroyer of life.

Thanks

Saturday, April 7, 2012

ASP.NET : Difference between Server.Transfer and response.Redirect

Response.Redirect sends message to the browser saying it to move to some different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server.

Using Server.Transfer you can not redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect.

With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page.

Use server.transfer to navigate within website. And use Response.redirect to redirect to another website.


You can transfer current users page request to another page with two methods:

    * Server.Transfer (HttpServerUtility.Transfer Method)
    * Response.Redirect (HttpResponse.Redirect Method)

Its not always clear how these two approaches differ so let us try to clarify things a little:

Response.Redirect sends HTTP code 302 down to the users browser along with the new URL location of the wanted page. 
HTTP Code 302 actually means ' The requested resource resides temporarily under a different URI'.
After browser receives this code it tries to open the new location of the resource that was suggested by the server.
This actually causes two requests to the server, first one to the original URL, and second to the new URL that is suggested via 302 response.
All the Query Strings and Form variables are lost during the redirect and they are not available to the redirected URL.

Also its important to say that the new URL can reside on the same server but also it can be on some other server and the redirected URL does not need to be .aspx page it can be regular HTML page also).

So we can us the Redirect method to redirect users request to another page on our server like this:

  Response.Redirect("newPage.html");

or to redirect our it to some other server like this:

  Response.Redirect("http://www.someotherserver.com/newPage.aspx");

In contrast to all this when we call Server.Transfer we do not initiate another request to the server, but the original request is simply rewritten and transfered to some other page on the same server.
(This off course means that we can use it only to transfer requests to the pages on the same server, not to some other servers and we can only transfer to .aspx pages and not other page types like HTML, php etc). 

All posted Form variables and query strings can optionally remain available to the second Page where we transfered request (if we use second overload Server.Transfer(string pathbool preserveForm) and supply true for the second parameter).
Otherwise the Form Variables and Query String are cleared just like when we use Redirect.
WARNING: If you use this method to preserve Query String and Form variables and receive error: "View State Is Invalid" its because your EnableViewStateMac attribute of the <pages> element is set to true. More on this error on this page: PRB: "View State Is Invalid" Error Message When You Use Server.Transfer

Its also important to note that because of the way Server.Transfer works, after the transfer, the URL shown in the users Web Browser remains the original one that was requested, because browser has no knowledge that its request was transfered (transfer occurs on the server side).
  
TIP: One thing to be careful about when using the Server.Transfer is to clear the the HttpResponse object withResponse.Clear method on the transfered page to avoid any output from the first page to be shown on the second page.

So now that we know what are the similarities and differences between these two approaches we can try to use them wisely.

Here is the summary:

Response.Redirect should be used when:
  • we want to redirect the request to some plain HTML pages on our server or to some other web server
  • we don't care about causing additional roundtrips to the server on each request
  • we do not need to preserve Query String and Form Variables from the original request
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)
Server.Transfer should be used when:
  • we want to transfer current page request to another .aspx page on the same server
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server
  • we want to preserve Query String and Form Variables (optionally)
  • we don't need to show the real URL where we redirected the request in the users Web Browser

Thursday, March 29, 2012

DBCC CHECKIDENT


Question

Which command is used reseed the identity value?

Answer

DBCC CHECKIDENT can be used to manually set a new current identity value for the identity column.
DBCC CHECKIDENT ("Sales.ProductType", RESEED, 10);