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.
"Steve C. Orr, MCSD" <St***@Orr.net> wrote in message
news:uK**************@TK2MSFTNGP10.phx.gbl...
Execute a line of code like this when you want a message box to be
displayed.
(This writes out the necessary client side javascript to your HTML page to
make the alert pop up as soon as the page is sent to their browser.)
RegisterStartupScript("startupScript", "<script
language=JavaScript>alert('This is my message.');</script>");
Here's more info:
http://msdn.microsoft.com/library/de...criptTopic.asp
--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Tom Wild" <tw***@lightknights.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl... 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