Click here to Skip to main content
11,705,762 members (52,367 online)
Click here to Skip to main content

Tagged as

ASP.NET web page goes blank with JavaScript alert()

, 13 Oct 2011 CPOL 5.8K
Rate this:
Please Sign up or sign in to vote.
Here simpler version. Using the overload method[^](parameter addScriptTags) you can reduce the code.private void ShowMessage(string Message){ if (!ClientScript.IsClientScriptBlockRegistered("MyMessage")) { ClientScript.RegisterClientScriptBlock(this.GetType(), "MyMessage",...
This is an old version of the currently published tip/trick.
Here simpler version. Using the overload method[^](parameter addScriptTags) you can reduce the code.
private void ShowMessage(string Message)
  if (!ClientScript.IsClientScriptBlockRegistered("MyMessage"))
    ClientScript.RegisterClientScriptBlock(this.GetType(), "MyMessage", Message, true);
public void btnTest_Click(Object sender, EventArgs e)
  ShowMessage("alert('Hello World');");
For AJAX - Updatepanel, use the below one
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(UpdatePanel), "MyMessage", Message, true);

Further Reading

ClientScriptManager.RegisterClientScriptBlock Method[^]
ScriptManager.RegisterClientScriptBlock Method[^]


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
Programmer | Dude | ||||||

About him & his blog? check out here. Currently he's updating the site, he'll return soon there with more things*.

In Codeproject, he posted a blogpost & more than couple of Tip/Tricks, hope he'll write more soon.

Favorite techs are MVC, WCF, Mobile, HTML5, CSS3, jQuery, etc.,

His hobbies are watching movies, CP, being alone, etc., But now he's working on something*.

* - SCAMP???

You may also be interested in...

Comments and Discussions

Discussions posted for the Published version of this article. Posting a message here will take you to the publicly available article in order to continue your conversation in public.
GeneralReason for my vote of 1 The user will need to pass the hardc... Pin
Balaji Birajdar14-Oct-11 5:42
memberBalaji Birajdar14-Oct-11 5:42 
GeneralRe: I agree that I forgot to add the alert keyword in the genera... Pin
thatraja14-Oct-11 5:57
mvpthatraja14-Oct-11 5:57 
GeneralRe: Reason for my vote of 1The user will need to pass the hardc... Pin
junaidcodeproject22-Aug-13 20:31
memberjunaidcodeproject22-Aug-13 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 13 Oct 2011
Article Copyright 2011 by thatraja
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid