Thursday, June 24, 2010

Using the Focus() method with the TextBox control

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Focus()
End Sub
C#
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Focus();
}

When the page using this method is loaded in the browser, the cursor is already placed inside of the text
box, ready for you to start typing. There is no need to move your mouse to get the cursor in place so you
can start entering information in the form. This is ideal for those folks who take a keyboard approach to
working with forms.

No comments:

Post a Comment