How to have a error create a pop-up?

  • Thread starter Thread starter REB
  • Start date Start date
R

REB

What is the code in C# to have a pop-up when a function throws an error?

catch(Exception ex)
{
Show pop up with text from ex in it?
}
 
you'll have to pass it to a clientside call.
javascript:alert('yourError');
perhaps, or a window.open() or a window.showModalDialog()
 
I often use the Page.RegisterStartupScript in an event handler to write a
javascript alert that can be based on a condition allows the entire page
loads before the alert pops up...very handy for me...

(note, this method also makes the message tablerow visible and writes to a
literal control in that row)
private void UserMessage(string Message, bool Popup)

{


StatusMessage.Text=Message;

ShowMessage.Visible=true;

if (Popup)

{

Page.RegisterStartupScript("StatusMessage","<SCRIPT
LANGUAGE=\"JavaScript\">alert('"+ Message +"');</Script>");

}

}
 
no... not unless you Response.Write() some clientside script.
There is not "open a new window" option in the Response.Write, sorry.
 
Does something like this work?

Response.Write("<SCRIPT LANGUAGE='JavaScript1.2'> alert('Error!')
</Script>");

Are there any drawbacks to using it this way?
 
Back
Top