Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 set focous on text box

Author  Topic 

chiragvm
Yak Posting Veteran

65 Posts

Posted - 2006-10-19 : 01:36:36
hi to all
i want to set focous on my textbox when the page load by default course set on my textbox i using this code but it not working proper

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Page.RegisterStartupScript("SetFocus", "<script language='Jscript'> document.getElementById('txtpassword').focus(); </script>")

End Sub

i use uper code in my form but not work proper
help me it urgunt

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-10-19 : 07:29:10
i use this simple function

Shared Sub SetFocus(ByVal ctl As System.Web.UI.Control, ByVal pg As System.Web.UI.Page)

Dim s As String

s = "<SCRIPT language=""javascript"""
s &= ">document.getElementById('" & ctl.ID & "').focus() </SCRIPT>"

pg.RegisterStartupScript("focus", s)

End Sub


[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -