Never been to DZone Snippets before?

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 (See related posts)

This code does a simple field focus in asp.net.

   1  
   2      Protected Sub setFieldFocus(ByVal ctrl As System.Web.UI.Control)
   3          Dim s As String = "<SCRIPT language='javascript'>document.getElementById('" + ctrl.ClientID + "').focus() </SCRIPT>"
   4          ClientScript.RegisterStartupScript(Me.GetType, "focus", s)
   5      End Sub
   6  
   7       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
   8          If Not Page.IsPostBack Then
   9              BindData()
  10          End If
  11          setFieldFocus(txtSpecies)
  12      End Sub

You need to create an account or log in to post comments to this site.


Click here to browse all 5355 code snippets

Related Posts