Home All Groups Group Topic Archive Search About
Author
22 Jun 2005 4:38 PM
dl
Hi
How do we set focus onto a textbox control ?  (in c# please!)

TIA

--

Author
22 Jun 2005 5:07 PM
JDP@Work
<dl> wrote in message news:uzsBPj0dFHA.3488@tk2msftngp13.phx.gbl...
> 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