Reputation: 2427
I need to be able to add an external js file for a user control (using
this.Page.ClientScript.RegisterClientScriptInclude("SuggestionSearch",
"~/Secure/Shared/SuggestionSearch.js");
syntax)
But it puts the javascript file on the page too early... is there a way to put the file at the bottom of the page?
Upvotes: 0
Views: 1531
Reputation: 5644
Take a look at ClientScriptManager.RegisterStartupScript
Something like this could work:
ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "SuggestionSearch",
String.Format("<script src='{0}' type='text/javascript'></script>", ResolveUrl("~/Secure/Shared/SuggestionSearch.js")));
Upvotes: 2