0

I want to write javascript from code behind but at the end of my HTML document. With Response.Write, I can write at the beginning of the file but how can I write at the end or in an other place ?

Thanks for your help !

5
  • You asking about WebForms or MVC? Commented Jan 26, 2015 at 9:02
  • Why does it matters ? I use WebForms. Commented Jan 26, 2015 at 9:05
  • You should use RegisterStartupScript. Commented Jan 26, 2015 at 9:06
  • Webforms... shudders Commented Jan 26, 2015 at 9:07
  • If you use Response.Write it would probably break the entire layout so your question possible duplicated of Here or Here Commented Jan 26, 2015 at 9:21

1 Answer 1

1

Write your JS function at the bottom of the HTML document, then just call it in the page load event in code behind file with

ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:someFunction();", true);
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.