Friday, 19 August 2011

Auto Complete Control in .Net

Write Code in .aspx Page
<asp:TextBox ID="txtbox1" runat="server"></asp:TextBox>

    <cc1:AutoCompleteExtender

      Enabled="true"

       UseContextKey ="true"

        MinimumPrefixLength ="1"

         ServiceMethod ="getdata"

           CompletionInterval="10"

        TargetControlID ="txtbox1"

     ID="AutoCompleteExtender2" runat="server">

    </cc1:AutoCompleteExtender>

Write a Method in .aspx.cs
using System.Collections.Generic;


[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string[] Getdata(string prefixText, int count,string contextKey)
{

List <string> response = new List <string>();

for (int i = 0; i =10; i++)
{
response.Add(prefixText+i);

}
return response.ToArray<string>();
}

Thursday, 11 August 2011

Validation of viewstate MAC failed

Error:-

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

Answer:-
if u get this error just add attribute EnableViewStateMac="false" in page tag

Example:-<%@ Page Language="C#" EnableViewStateMac="false" >

Tuesday, 9 August 2011

Get lable control text in javascript

var x = document.getElementById('<%=LableId.ClientID %>').textContent;

this work in firefox also

Sunday, 7 August 2011

Sql Server identity

identity
To change identity first drop identity column and then add new identity column like
this example

drop identity column

alter table tb_name
drop column col_name

add identity column

alter table tb_name
add columnname int identity(100,1)