DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Setting Focus To A Field In Asp.net
This code does a simple field focus in asp.net.
Protected Sub setFieldFocus(ByVal ctrl As System.Web.UI.Control)
Dim s As String = "<SCRIPT language='javascript'>document.getElementById('" + ctrl.ClientID + "').focus() </SCRIPT>"
ClientScript.RegisterStartupScript(Me.GetType, "focus", s)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindData()
End If
setFieldFocus(txtSpecies)
End Sub




