Wednesday, April 22, 2009

Textbox Set Focus on Load while using AJAX Controls on Page

Textbox Set Focus on Load while using AJAX Controls on Page


Whenever you are using AJAX Controls on Page, always remember that
normal way of making set Focus to textbox controls won't work.

Solution to this Problem:
protected void Page_Load(object sender, EventArgs e)
{
AjaxControlToolkit.Utility.SetFocusOnLoad(txtEmailId);
}
Where, txtEmailId is control name.

In every other case where you are not using AJAX Control on Page load and your
.Net Application is in VS.Net 2005 or above version, you can try using following

protected void Page_Load(object sender, EventArgs e)
{

this.Form.DefaultFocus = this.txtEmailId.ClientID;
}

Note: There are various techniques i have discuss most commonly used
technique to set focus for textbox control.

2 comments:

Anonymous said...

Nice one - did the trick.

Unknown said...

simple and effective. thanks!

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape