Re: Oh the machinations!



Hi Steve,

> I do think it's quite pathetic there is no practical means to perform
> this very routine event (pop-up message box).

It certainly is routine. However, don't you think it's quite pathetic that,
rather than creating your own function to do something like this, you
complain because Microsoft hasn't? A good programmer can write his own
tools. But never mind that; here's one of mine:

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

/// <summary>
/// Adds a JavaScript "alert()" with Message to Page Startup
/// </summary>
/// <param name="Message">Message to display</param>
public static void MsgBox(string Message)
{
MsgBox(Message, "MsgBox");
}

Note: You will have to come up with your own custom Exception Handler, or
just throw the Exception if you like.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

<zamdrist@xxxxxxxxx> wrote in message
news:1126037594.191002.85650@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Thank you all for your suggestions.
>
> I do think it's quite pathetic there is no practical means to perform
> this very routine event (pop-up message box).
>
> For all its grandeur, ASP.Net can't even do what windows forms have
> been doing for years and years.
>
> Again, thank you for the suggestions.
>
> Steve
>


.