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

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!

Leave a Reply