How do i add my javascript file as an embeded resource to the page after the ajax javascript already on the page? NB want to do this part dynamically to have code wrapped up in usercontrol.
in aspx page: scriptmanager
Code: Assembly: WebResource(“Functions.js”, “text/javascript”)
Code: onPreRender:
ScriptManager.RegisterClientScriptResource(Me.Page, Me.GetType().BaseType, “Functions.js”)
This code successfully adds my javascript code to the page but not after the AJAX javascript and so not all of my functions work correctly.
Thanks, Dave
You could use GetWebResourceUrl() to get the path string to your embeded script as it should be in the page (probably something like websresource.axd?XXXX). Then manually insert a script tag pointing to the path using RegisterStartupScript to force it to be added at the end of the page. Something like below…
From the server you could also try adding your script later in the load process for example in the prerender event. Or from the client side can wrap your script into a load so that it doesn’t run the code until the last possible moment as below…