Click here to Skip to main content
13,506,180 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 13 Oct 2011

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

, 17 Oct 2011
Rate this:
Please Sign up or sign in to vote.
How to fix the issues when an ASP.NET web page goes blank with JavaScript alert() .

An ASP.NET web page goes blank if you inject the JavaScript alert(); function using Response.Write from the code-behind. Here is a fix for it.

private void ShowMessage(string message)
		String scriptMessage = "<script language='javascript'>function window.onload(){alert('" + message + "');}</script>";
		if (!ClientScript.IsClientScriptBlockRegistered("MyMessage"))
			ClientScript.RegisterClientScriptBlock(this.GetType(),"MyMessage", scriptMessage.ToString());


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
Software developer by profession, working for a service and product based organisation in India.

Career graph:
Software Programmer since 2002.
Web Developer in ASP.NET since 2004.

I love reading the blogs and articles of technology experts. I love codeproject and stackoverflow .

I love to share knowledge and help the programmers. I appreciate if some body corrects my code or my concepts which helps me learn.

You may also be interested in...

Comments and Discussions

GeneralI have faced same problem with alert() function. what is re... Pin
udusat1316-Oct-11 19:06
memberudusat1316-Oct-11 19:06 

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

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

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180417.1 | Last Updated 17 Oct 2011
Article Copyright 2011 by npm-prune
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid