Saturday, 14 July 2012

Beginning .Net : Set focus to a TextBox on web page load

There is a situation where you need to focus on text box after page is loaded.
This is the best user friendly concept.

You can do this with two ways.
First use .Focus() method of TextBox Control.
Second use Page.SetFocus method.

Here is example for this.

C# Example :
 //Use Focus method of textbox

 //Use SetFocus method of Page
 Page.SetFocus(txtProductName); Example :
''Use Focus method of textbox

''Use SetFocus method of Page

 You can use anyone method from above. Do not use both method at a time.

This article is very useful for .Net Beginners.

Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.

No comments:

Post a Comment