set focus

Discussion in 'ASP .Net Web Controls' started by Guest, Jun 22, 2005.

  1. Guest

    Guest Guest

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

    TIA

    --
     
    Guest, Jun 22, 2005
    #1
    1. Advertising

  2. Guest

    JDP@Work Guest

    <dl> wrote in message news:...
    > 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
     
    JDP@Work, Jun 22, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manav
    Replies:
    0
    Views:
    808
    Manav
    Oct 15, 2003
  2. Jason
    Replies:
    4
    Views:
    1,683
    Jason
    May 7, 2007
  3. Replies:
    2
    Views:
    359
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  4. Roger
    Replies:
    3
    Views:
    379
  5. Jeff

    manual focus vs. focus()

    Jeff, May 20, 2007, in forum: Javascript
    Replies:
    4
    Views:
    197
Loading...

Share This Page