registering javascript

T

Timothy Elvidge

I have a menu control that is embedded in each web page. The menu requires javascript for the mouseover events. I have tried Page.RegisterClientScriptBlock and
Page.RegisterStartupScript to no avail. The script doesn't appear on the parent page?? What to do?
 
X

XicoLoKo

When do you call the Page.RegisterClientScriptBlock?
What key are you using to uniquely identify each script?
 
T

Teemu Keiski

To add to this that registering needs to happen in OnPreRender at the
latest. In Render it is too late because render process has begun for the
Page already.


--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke



XicoLoKo said:
When do you call the Page.RegisterClientScriptBlock?
What key are you using to uniquely identify each script?
requires javascript for the mouseover events. I have tried
Page.RegisterClientScriptBlock andparent page?? What to do?
 
M

Mr. Dot Net

Is it possible that you use output cache for that control?

Timothy Elvidge said:
I have a menu control that is embedded in each web page. The menu requires
javascript for the mouseover events. I have tried
Page.RegisterClientScriptBlock and
Page.RegisterStartupScript to no avail. The script doesn't appear on the
parent page?? What to do?
 
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.
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top