I m using some serverside validation and if any problem comes I m showing a pop up message using javascript using
page.ClientScript.RegisterClientScriptBlock
but when my message is displayed the background of the window turns gray.
can any one help me to get rid of this gray window
public static class Alert
{
/// <summary>
/// Shows a client-side JavaScript alert in the browser.
/// </summary>
/// <param name="message">The message to appear in the alert.</param>
public static void Show(string message)
{
// Cleans the message to allow single quotation marks
string cleanMessage = message.Replace("'", "\\'");
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(Alert), "alert", script);
}
}
}
I am using this Function
Since you are using the Javascript alert() function, you have absolutely no control over how the browser handles it. Each browser looks slightly different. However, you can expect that it will be a modal popup with your content, and a single "Ok" button. Beyond that, you have no control.
If you want something different, you'll have to use more complex javascript; perhaps using a jQuery plugin to display your message exactly how you want, or overriding the alert() function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.