How to have a error create a pop-up?

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?
}
 
C

Curt_C [MVP]

you'll have to pass it to a clientside call.
javascript:alert('yourError');
perhaps, or a window.open() or a window.showModalDialog()
 
E

Earl Teigrob

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>");

}

}
 
C

Curt_C [MVP]

no... not unless you Response.Write() some clientside script.
There is not "open a new window" option in the Response.Write, sorry.
 
R

REB

Does something like this work?

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

Are there any drawbacks to using it this way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top