Call javascript function without using any event call

C

cschang

In my vb.net module, I used the script to generate a client side
javascript function. as
Private Sub disablePostedFileInout(ByVal n As Integer)
Dim jScript As String

jScript = "<script language='javascript'>"
jScript = jScript & " function disableInput(" & n & " ) { "
jScript = jScript & " var j = 0; "
jScript = jScript & " for( var i =0; i<
document.form1.elements.length; i++){"
jScript = jScript & " if( document.form1.elements.type
=='file') { "
jScript = jScript & "
document.form1.elements.style.visibility = 'hidden'; "
jScript = jScript & " if ( (j + 1) == " & n & " ) return; "
jScript = jScript & " } ) } "
jScript = jScript & "</script>"

If (Not IsClientScriptBlockRegistered("clientScript")) Then
RegisterClientScriptBlock("clientScript", jScript)
End If

End Sub

Is possible I can just call the javascript function "disableInput"
without associating it in any event of the control such as button or
input as some kind of onclick, onchange etc? I want to run it from
another sub of the module

C Chang
 
C

Cor Ligthert

Cshang,

The answer is as R.Thomas already wrote that you can use the
registerstartupscript. Here the link how to use that

http://msdn.microsoft.com/library/d...mwebuipageclassregisterstartupscripttopic.asp

I think it is next time better to ask this kind of questions in the
newsgroup.

Aspnet
news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet

Web interface:
http://communities2.microsoft.com/c.../?dg=microsoft.public.dotnet.framework.aspnet

Or one of the language newsgroups

I hope this helps

Cor
 
C

cschang

Cor said:
Cshang,

The answer is as R.Thomas already wrote that you can use the
registerstartupscript. Here the link how to use that

http://msdn.microsoft.com/library/d...mwebuipageclassregisterstartupscripttopic.asp

I think it is next time better to ask this kind of questions in the
newsgroup.

Aspnet
news://msnews.microsoft.com/microsoft.public.dotnet.framework.aspnet

Web interface:
http://communities2.microsoft.com/c.../?dg=microsoft.public.dotnet.framework.aspnet

Or one of the language newsgroups

I hope this helps

Cor
Thanks, Cor. I will go to those links to check out. I started to learn
the .net (mainly by vb.net) because of the work, just starting off right
before las Xmas. So I have not much idea where I can post my questions.

C Chang.
 

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

Top