In my Page_Load I identify the page header block from my master page and add javascript from an XML file to that part of the page.
It doesn't seem to be loading in time. If I explicitly put the script reference on the page, it works. But not when I load through the page_load event.
Should it be loaded sooner?
You're not adding any code so I'm not able to tell you what you're doing wrong. Instead, I'll tell you a valid way to add script references from code behind.
Something like this on Page_Load should do the trick
var js = new HtmlGenericControl("script");
js.Attributes["type"] = "text/javascript";
js.Attributes["src"] = "myFile.js";
Page.Header.Controls.Add(js);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With