registering javascript block - help!

  • Thread starter Thread starter Bob H
  • Start date Start date
B

Bob H

Hi,

I'm trying to register a javascript function from the Page Load event:

If (Not IsClientScriptBlockRegistered("Check")) Then
Dim str As String = "<script language=javascript>Check()<script>"
RegisterClientScriptBlock("Check", str)
End If

....but the page just comes up blank. If I take the above out, the page &
javascript work okay.

Any ideas as to what is wrong/may be happening?

Many thanks for any advice.

Regards

Bob
 
Try adding the Page to this line
RegisterClientScriptBlock("Check", str)

Try it as:
Page.RegisterClientScriptBlock("Check", str)

-Stanley
 
The closing tag for the script block should be '</script>', not '<script>'.
 
Thanks for the tips.

The Page is now working, but the javascript function (for test purposes a
window.alert) is being run everytime the Page is being loaded:

If (Not IsClientScriptBlockRegistered("Check")) Then
Dim str As String = "<script language=javascript>Check()</script>"
Page.RegisterClientScriptBlock("Check", str)
End If
ibtnSubmit.Attributes.Add("OnClick", "javascript:return Check();")

The Javascript function is in the HTML file in the HEAD section. If I take
out the registration block, the javascript isn't run until the ibutton is
clicked.

Any further clues please??

Thanks

Bob
 

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

Back
Top