Javascript is not working with update panel- Microsoft Ajax

As an 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 page like following…

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

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

Technorati Tags: ,,,,


  1. Its Working Now...
    You Releive me form a Big Torture...
    Thank U So much..

  2. Hey Buddy yeah u saved my day too.. thanks a lot

  3. wow, that's great article
    its working now...
    thanks for your info...

  4. If the script is on the aspx page. How will we register that.

    Thanks in advance

  5. for example you have javascript function foo() in your aspx page then you can register like this.

    string alertScript = "javascript:foo();";

    ClientScript.RegisterStartupScript(typeof(Page),"alertscript", alertScript);

    Its very simple create a javascript function and register that.


  6. I'm getting a message in my C# codebehind function that calls the ScriptManager.RegisterStartupScript method that says the I 'Cannot access static method 'RegisterStartupScript' in non-static context'. Any ideas how to fix this?

  7. thank u soo much...........

  8. Glad You liked it.. Thanks for putting comment!!

  9. Thank you very much Jalpesh!

  10. thansk alooooooottttttttttttt

  11. My problem no longer exists!!!


Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

Popular posts from this blog

Creating PDF with ASP.Net MVC and RazorPDF

Horizontal and vertical scrollbar in HTML5 and CSS3

How to create Rest API(Web API) with ASP.NET Core 1.0