Tuesday 17 August, 2010

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.

No comments:

Post a Comment