Saturday, July 19, 2014

How to run JavaScript function from code behind in ASP.NET C#

Every time we access JavaScript or Jquery from the aspx page or html page. But some times its really necessary to access the javascript function from the code behind. So today  in this example I will show you all how to call a javascript function or e\write your javascript code in code behind.

To show an alert pop up box the simplest code is..

Response.Write("<script type="text/javascript">alert('Your message');</script>")

But I will show you a better option to do that one.

ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert", "alert('Your message');", true);

Within "alert('Your message');" aa call your javascript function or write your code, what ever you want.

For more details go through this link


Post a Comment

Popular Posts