How to show a client-side message box at the next page load in ASP.NET

Dec 17, 2009 Posted by Lara Kannan
Showing a client-side message box at the next page load by use the below technique.

' Show a client-side message box at the next page load
' Example:
' ShowMessageBox(Me, "Order successfully submitted!")

public void ShowMessageBox(System.Web.UI.Page webPage, string message)
{
// replace ' with \', otherwise the resulting javascript may raise errors
message = message.Replace("'", "\\'");

// create the script and add it to the page's response
string script = "";
if ((!webPage.IsStartupScriptRegistered("StartupAlert")))
{
webPage.RegisterStartupScript("StartupAlert", script);
}
}

Happy Coding!
Share
Labels: , ,

Post a Comment