Sunday, February 4, 2007

Set Focus

In ASP.net there are 2 ways to set focus to a textbox. One uses the defaultfocus property of the form tag and the other uses the SetFocus method in the code behind.

1. defaultfocus (web form)

<form id="frmFocus" runat="server" defaultfocus="txtSecond">

2. SetFocus (code behind)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   Me.SetFocus("textbox")
End Sub

Labels:

0 Comments:

Post a Comment

<< Home