Calling Set Focus Function From Many Pages

G

Guest

Hi,

I have a setfocus that works fine:

Private Sub SetFocus(ByVal ctrl As Control)
Dim focusScript As String = "<script language='javascript'>" & _
"document.getElementById('" + ctrl.ClientID & _
"').focus();</script>"
Page.RegisterStartupScript("FocusScript", focusScript)
End Sub

Is there a way I can put this in a modue and send in the Page name as a constraint so that I can just declare the function once instead of all over the place? I have tried something (but not exactly) like this...

Private Sub SetFocus(ByVal ctrl As Control, Byref pPage As Page)
Dim focusScript As String = "<script language='javascript'>" & _
"document.getElementById('" + ctrl.ClientID & _
"').focus();</script>"
pPage.RegisterStartupScript("FocusScript", focusScript)
End Sub

but Im missing something.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top