Thursday 16 April 2015

asp.net write script in the page at run-time

There are many ways to write scripts inside html page using c# code behind, some of them

The following code snippet will append the script at the end of the page

ClientScript.RegisterStartupScript(this.GetType(), "keyOfScript", "console.info('Mohammad');", true);

The following code snippet will append the script at the beginning of the page

Response.Write("< script >console.info('Mohammad');< / script>");

No comments:

Post a Comment