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());
}
}
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.
Interests:
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.