Thursday, July 23, 2009

Javascript is not working with update panel- Microsoft Ajax

As an asp.net developer we all must have to use update panel for the ajaxifying our application in today’s ajax world. No one likes postaback now. But when we add the some content with the java script under update panel then some times it’s stop working because of the update panel server side behavior. So what we should do? … Here is the trick. Normally we code java script in the asp.net page like following…

string alertScript = "javascript:alert('Alter From asp.net page')";
ClientScript.RegisterStartupScript(typeof(Page),"alertscript", alertScript);
Instead of this you should use.

string alertScript = "javascript: alert('This is aler from asp.net page')";
ScriptManager.RegisterStartupScript(this, this.GetType(), "alertScript",
                                alertScript,true);
This will work. Happy coding..

Technorati Tags: ,,,,
Share:

Related Posts:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews