Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Focus

Status
Not open for further replies.

Linda224

Programmer
Joined
Dec 6, 2006
Messages
80
Location
US
Hello

I am working on a vb.net web form where after hiting submit I want the curser to set focus in a text box. Does any one know how to do that?

Thank you!
 
Yes, you'll have to use the javascript "focus" method.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
If you are Using VS2005, the 2.0 framework as a .focus method on the textbox control.
 
if your using VS2003 you can do something like this

Private Sub SetFocus(ByVal ctrl As System.Web.UI.Control)

Dim s As String = "<SCRIPT language='javascript'>document.getElementById('" & ctrl.ID & "').focus() </SCRIPT>"

RegisterStartupScript("focus", s)

End Sub

Then use SetFocus(TextBox)

there are a few different ways to do this. try searching the forum as well.

 
Thank you guys for your help
The Javascript worked perfect!
-Linda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top