0

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?

1
  • Have you looked at jquery? api.jquery.com/ready If you have to use that syntax, I'm not sure there is a way to put the file at the bottom. Commented Dec 2, 2010 at 6:11

1 Answer 1

2

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")));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.