Using JavaScript Display message

Gow.Net
Posted by Gow.Net under ASP.NET category on | Points: 40 | Views : 1305
Using JavaScript Display message
public static void ShowMessage(string Message)
{
string cleanMessage = Message.Replace("'", "\\'");
//jscript
string script = "<script type=\"text/javascript\">alert('" + cleanMessage + "');</script>";

// Gets the executing web page
Page page = HttpContext.Current.CurrentHandler as Page;

// Checks if the handler is a Page and that the script isn't allready on the Page
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
{
page.ClientScript.RegisterClientScriptBlock(typeof(AlertMessage), "alert", script);
}
}

Comments or Responses

Login to post response