CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: textbox

  1. #1
    Join Date
    Aug 2005
    Posts
    1

    textbox

    how to put focus on textbox?

  2. #2
    Join Date
    Mar 2005
    Location
    India
    Posts
    102

    Re: textbox

    You can write a javascript code in the code behind class

    Here is an example This might be helpful, I have not tried it ..

    Protected Sub SetFocus(ByVal ctrl As Control)
    Dim strbuild As New System.Text.StringBuilder("")
    With strbuild
    .Append("<script language='JavaScript'>")
    .Append("function SetFocus()")
    .Append("{")
    .Append("document.")
    .Append(ctrl.Parent.ID)
    .Append("['")
    .Append(ctrl.UniqueID)
    .Append("'].focus();")
    .Append("}")
    .Append("window.onload = SetFocus;")
    .Append("")
    .Append("</script")
    .Append(">")
    End With
    ctrl.Page.RegisterClientScriptBlock("SetFocus", strbuild.ToString())
    End Sub

    Call SetFocus(textbox1) in the page load event

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured