M
moondaddy
I'm using vb.net 1.1 and have an aspx page that I want some jscript to run
when the page loads on the client. Also I want this script to use logic
provided from the server in the Page_Load event. for example, if some
server side logic were true then when the page loads I would want the script
to change the text in a label in a different frame. If the server side
logic were false, then I would want to change the text in that same label to
something different again. I know I can generate jscript from the server
that would contain this logic by using something like this:
RegisterClientScriptBlock("clientScript", scriptString)
If (Not Page.IsClientScriptBlockRegistered("clientScript")) Then
Page.RegisterClientScriptBlock("clientScript", scriptString)
End If
But how can I get this code to run when the page loads on the client?
In the past I've used this line on the client to call a function when the
page loads, but I don't like it because it runs twice when the page loads:
document.onreadystatechange=myFunc;
Any good ideas for a better way to do this?
when the page loads on the client. Also I want this script to use logic
provided from the server in the Page_Load event. for example, if some
server side logic were true then when the page loads I would want the script
to change the text in a label in a different frame. If the server side
logic were false, then I would want to change the text in that same label to
something different again. I know I can generate jscript from the server
that would contain this logic by using something like this:
RegisterClientScriptBlock("clientScript", scriptString)
If (Not Page.IsClientScriptBlockRegistered("clientScript")) Then
Page.RegisterClientScriptBlock("clientScript", scriptString)
End If
But how can I get this code to run when the page loads on the client?
In the past I've used this line on the client to call a function when the
page loads, but I don't like it because it runs twice when the page loads:
document.onreadystatechange=myFunc;
Any good ideas for a better way to do this?