Skip to content Skip to sidebar Skip to footer

Call Javascript Function From Asp.net Code Behind

I’m trying to call a JavaScript function from Code behind but no luck so far. I tried to add the following snippets inside Page_Load method. I’ve tried as below ScriptManager.R

Solution 1:

You are missing a ; in you code. Try this it worked for me.

But i would suggest the ScriptManager.RegisterStartupScript over the Page.ClientScript.RegisterStartupScript as the first one is designed for AJAX calls. Which will work for even partial page post backs.

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "foo", "alert('test22222');", true);

Solution 2:

This will work. You forgot semicolon at end of your alert:

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "foo", "alert('test22222');", true);

Post a Comment for "Call Javascript Function From Asp.net Code Behind"