Friday, October 25, 2013

IE11 and Windows 8.1 : Solution for __doPostBack and Ajax not working

When we tested our website against latest IE 11 browser then we came to know that our website is not working properly against IE 11 browser.

I tried to find out on the solution for this issue and i found out following ways which will help us to resolve issue on IE 11 browser.

​Following Steps are performed to fix IE 11: ajax and __dopostback issues:
You can upgrade to .net framework 4.5 which will help us to resolve issue. If you can not update then we have some temporary alternative solution.

There are 2 solutions:

1. Site Level Fix:

Nuget has provided an update for the browser, you can execute the co

   step 1: Perform Steps from following links
   step 2: In ie.browser add mentioned settings from following link

In your project, add to (or create as) App_Browsers/ie.browser, the following:

<!-- Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko -->
<browser id="IE11Preview" parentID="Mozilla">
        <userAgent match="Trident/(?'layoutVersion'\d+).*rv:(?'revision'(?'major'\d+)(\.(?'minor'\d+)?))" />
        <userAgent nonMatch="MSIE" />

        <capability name="browser"              value="IE" />
        <capability name="layoutEngine"         value="Trident" />
        <capability name="layoutEngineVersion"  value="${layoutVersion}" />
        <capability name="isColor"              value="true" />
        <capability name="screenBitDepth"       value="8" />
        <capability name="ecmascriptversion"    value="3.0" />
        <capability name="jscriptversion"       value="6.0" />
        <capability name="javascript"           value="true" />
        <capability name="javascriptversion"    value="1.5" />
        <capability name="w3cdomversion"        value="1.0" />
        <capability name="ExchangeOmaSupported" value="true" />
        <capability name="activexcontrols"      value="true" />
        <capability name="backgroundsounds"     value="true" />
        <capability name="cookies"              value="true" />
        <capability name="frames"               value="true" />
        <capability name="javaapplets"          value="true" />
        <capability name="supportsCallback"     value="true" />
        <capability name="supportsFileUpload"   value="true" />
        <capability name="supportsMultilineTextBoxDisplay" value="true" />
        <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
         <capability name="supportsVCard"        value="true" />
        <capability name="supportsXmlHttp"      value="true" />
        <capability name="tables"               value="true" />
        <capability name="supportsAccessKeyAttribute"    value="true" />
        <capability name="tagwriter"            value="System.Web.UI.HtmlTextWriter" />
        <capability name="vbscript"             value="true" />
        <capability name="revmajor"             value="${major}" />
        <capability name="revminor"             value="${minor}" />


Once you perform above mentioned steps, your issue will be resolved.

2. Machine Level Fix:

   Step 1: Download patch from following link.
   Step 2: install patch

   Main Source:

With the help of above fixes you can fix issue.

Happy Coding!!

Wednesday, October 2, 2013

SQL Server: Insert missing Identity Column Values

When we set identity to a particular column, we dont need to pass value for that column.
SQL Server automatically increments its value.

Suppose if we inserts 10 records and deleted last record. Maximum value will be 9 but when we add new record then SQL server takes next value as 11 not it doesn't take 10. Because we already added record in 10th position and deleted after it.
CREATE TABLE [dbo].[Student](
[Sno] [int] IDENTITY(1,1) NOT NULL,
[Sname] [nvarchar](50) NULL,
[Saddrs] [nvarchar](50) NULL
insert into student(sname,saddrs) values('Abhi','India')
insert into student(sname,saddrs) values('Sourav','Japan')
insert into student(sname,saddrs) values('david','US')
insert into student(sname,saddrs) values('rahul','UK')
insert into student(sname,saddrs) values('gautam','Australia')
insert into student(sname,saddrs) values('jonathan','Germany')
insert into student(sname,saddrs) values('prasad','Pune')
insert into student(sname,saddrs) values('sandeep','Pune')
insert into student(sname,saddrs) values('john','Pune')
insert into student(sname,saddrs) values('sanjay','Pune')

Now we will delete sno=10
delete from student where sno=10
After Record deleted

Now If we add new record then it will take sno=11 but we want to add sno=10
If you try to insert value at sno=10, it will give you an error as  shown in below screenshot.

In this case we need to insert value manually by turning off identity feature off. After inserted manually we need to identity turn on  again.

SET IDENTITY_INSERT TABLE-NAME  ON :turns off identity increment. Specify table name on which you want to turn off identity

Your Insert Statement, you need to provide identity column value because in previous command you have turned off autoincrement. Provide missing identity values which you want to add.
Example: Student is table in which sno is identity column.
I have 10 records, i have deleted last record i.e sno=10 now i want to add value for sno=10

My query will be
insert into student(Sno,sname,saddrs) values(10,'sachin','Pune')

After Above Query Result will be


SET IDENTITY_INSERT TABLE-NAME  OFF:turns on identity increment.
Now your autoincrement will be started, you dont need to provide value for identity column.

Now If you try to provide value then sql server will give you an error.
insert into student(Sno,sname,saddrs) values(11,'Rakesh','Pune')

I hope this article helps you to understand how to insert missing identity column values.

Happy Coding!!

Paging In SQL Server with derived table and CTE

In this article we will check how can we do paging.

First We will create table

create table RecordTable(col1 int, col2 int)

Now we will insert records into the table.

insert into RecordTable
select 1,1
union all
select 1,2
union all
select 1,3
union all
select 1,4
union all
select 1,5
union all
select 1,6
union all

select 1,7

We will do it through in 2 ways.
1. With Derived Table
2. With Common Table Expression.

Mostly performance is same in both ways, in some scenario it may vary.

1.Paging with Derived Table
select * from(
select col1,col2,
ROW_NUMBER() over( order by col1)  as rowno
from RecordTable)
where rowno>minNo and rowno<MaxNo

2. Paging with CTE
;with ctedup as(
select col1,col2,
ROW_NUMBER() over( order by col1)  as rowno
from duplicateRecordTable)
select * from ctedup
where rowno>MinNo and rowno<MaxNo

It will gives you records in between min and max no.

Happy Coding!!