J
Jonathan Wood
I've created some javascript and added it to my page (from a user control)
using Page.ClientScript.RegisterClientScriptBlock. The javascript hides and
shows certain elements in response to radio buttons being selected.
It seems to work fine except that I really need to run the script when the
page loads so the required elements are shown or hidden (some of these
elements do not have runat="server").
So, I use the following code:
Page.Form.Attributes.Add("onload", initFunction);
Where initFunction is something like "OnUserFood()".
This seems to have no effect. And looking at the resulting HTML, I notice
that my script appears within the form instead of in the header. I'm not
sure if this matters. But, although the onload attribute correctly appears
in the form tag, again, it doesn't appear to be actually making the call.
Any suggestions?
Thanks.
using Page.ClientScript.RegisterClientScriptBlock. The javascript hides and
shows certain elements in response to radio buttons being selected.
It seems to work fine except that I really need to run the script when the
page loads so the required elements are shown or hidden (some of these
elements do not have runat="server").
So, I use the following code:
Page.Form.Attributes.Add("onload", initFunction);
Where initFunction is something like "OnUserFood()".
This seems to have no effect. And looking at the resulting HTML, I notice
that my script appears within the form instead of in the header. I'm not
sure if this matters. But, although the onload attribute correctly appears
in the form tag, again, it doesn't appear to be actually making the call.
Any suggestions?
Thanks.