Set Focus of Controls in ASP.NET

Santosh4u
Posted by Santosh4u under ASP.NET category on | Views : 2317
Refer Below Code to Set the Focus of a Control in asp.net
you need to call this method where you want to set focus of control.
  Private Sub SetFocus(ByVal FocusControl As Control)
Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
With Script
.Append("<script language='javascript'>")
.Append("document.getElementById('")
.Append(ClientID)
.Append("').focus();")
.Append("</script>")
End With
RegisterStartupScript("setFocus", Script.ToString())
End Sub

Regards
Santosh

Comments or Responses

Login to post response