Cassio Posted August 13, 2003 Posted August 13, 2003 Hi! I have the following code to set the focus on a webform control: Private Sub SetFocus(ByVal ctlName As String) Dim sb As String sb = "<script language=javascript>" sb = sb + "function setFocus(ctl)" sb = sb + "{" sb = sb + "if (document.forms[0][ctl] != null)" sb = sb + "{" sb = sb + "document.forms[0][ctl].focus();" sb = sb + "}" sb = sb + "}" sb = sb + "setFocus('" sb = sb + ctlName sb = sb + "');" sb = sb + "</script>" If Not IsStartupScriptRegistered("InputFocusHandler") Then RegisterStartupScript("InputFocusHandler", sb.ToString()) Session("strInputFocus") = ctlName End If End Sub How can I put it ito a class or a webservice or even a user cotrol so I can call this sub from every form in my project? Thanks? Quote Stream of Consciousness (My blog)
Moderators Robby Posted August 14, 2003 Moderators Posted August 14, 2003 try using a function instead of a sub.. Private Function SetFocus(ByVal ctlName As String) As String 'your code Return sb End Function Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.