ASP.NET & message box

  • Thread starter Thread starter DzemoT.
  • Start date Start date
If you only need an alert box,

/// <summary>
/// Adds a JavaScript "alert()" with strMessage to Page Startup
/// </summary>
/// <param name="strMessage">Message to display</param>
public static void MsgBox(string strMessage)
{
StringBuilder s;
System.Web.UI.Page p;
if (HttpContext.Current == null) return;
s = new StringBuilder("<script type=\"text/javascript\">" +
Environment.NewLine +
"<!--" + Environment.NewLine);
s.Append("alert('" + strMessage.Replace("\"", "\\\"") + "');" +
Environment.NewLine + "// --></script>");
p = (System.Web.UI.Page) HttpContext.Current.Handler;
if (!(p.IsStartupScriptRegistered("MsgBox")))
p.RegisterStartupScript("MsgBox", s.ToString());
}

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

bassil said:
You can try this one:

MessageBox for ASP.NET from http://www.bassilsoft.com

MessageBox is a handy component to create a message box on a Web page in
seconds.
 
Back
Top