Webforms equivalent of a Message Box

  • Thread starter Thread starter Tom Wild
  • Start date Start date
T

Tom Wild

Hi

Is there an equivalent of the message box that can be used for webforms?
When I try to use a normal message box I get the following error:

"It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode. Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service
application."

Thanks

Tom
 
This might come in handy for some folks. It's a MsgBox function I created
for ASP.Net apps to use:

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

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Back
Top