set focus

J

JDP@Work

Hi
How do we set focus onto a textbox control ? (in c# please!)

TIA

Sorry here's some VB.Net that sets the focus to the textbox DistMgrNumber.

Note that clientID is a property.

You may wish to google or MSN RegisterStartUpScript

.....snipit

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Me.setProgramTypePanelVisibility(Me.ddlProgramType.SelectedValue)
End If

If Not Page.IsStartupScriptRegistered("DistFocusScript") Then
Page.RegisterStartupScript("DistFocusScript", Me.getDistFocusScript)
End Sub

.... do stuff

Private Function getDistFocusScript() As String
Dim sb As New System.Text.StringBuilder

sb.Append("<script language=""javascript"">")
sb.AppendFormat("document.Form1.{0}.focus();", Me.tbDMNumber.ClientID)
sb.Append("</script>")

Return sb.ToString
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top