Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...