Javascript

T

Timothy Elvidge

I have moved the following to the parent page for the menu control and I still can't see the Javascript appearing. This is what I am doing:-
protected override void OnPreRender (System.EventArgs e)
{
Page.RegisterClientScriptBlock ("menuscript", "<script language=\"javascript\" src=\"default.js\"></script>\n");
}
I can use the ControlAt and write the script block as a literal control but would like to do this the right way.
 
D

Dale

Move your code out of the control's OnPreRender and into the Page_Load event
handler.

But in this case, why not just hardcode the script block HTML into the ASPX
page? You're using server resources here to generate something that is
always the same and always known ahead of time. The server processing isn't
adding anything at all to the final outcome.

Dale



Timothy Elvidge said:
I have moved the following to the parent page for the menu control and I
still can't see the Javascript appearing. This is what I am doing:-
protected override void OnPreRender (System.EventArgs e)
{
Page.RegisterClientScriptBlock ("menuscript", "<script
language=\"javascript\" src=\"default.js\"> said:
}
I can use the ControlAt and write the script block as a literal control
but would like to do this the right way.
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top