Alert message not shown

M

Miguel Gómez

Hi guys:

Please take a look to the following code:

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" + ex.Message.ToString() + "')</script>");

this.ExitPage();
}


The code's behaviour is that the "ExitPage()" procedure is executed, but the alert message does not show.

If I comment the call to the "ExitPage()" procedure , then the alert message is shown pretty well.

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" + ex.Message.ToString() + "')</script>");

//this.SalirDelaPagina();
}

What I need is that the alert message shows, and then the "ExitPage()" procedure executes in order to exit the page correctly.

Any suggestion, please??

I'm becoming crazy.

Thanks to all.

Miguel
 
H

Hans Kesting

Miguel Gómez formulated on vrijdag :
Hi guys:

Please take a look to the following code:

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" +
ex.Message.ToString() + "')</script>");

this.ExitPage();
}


The code's behaviour is that the "ExitPage()" procedure is executed, but the
alert message does not show.

If I comment the call to the "ExitPage()" procedure , then the alert message
is shown pretty well.

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" +
ex.Message.ToString() + "')</script>");

//this.SalirDelaPagina();
}

What I need is that the alert message shows, and then the "ExitPage()"
procedure executes in order to exit the page correctly.

Any suggestion, please??

I'm becoming crazy.

Thanks to all.

Miguel

What is that ExitPage() doing? Does it perform a redirect? If so,
anything written to the response is canceled.
You can't show a message in the browser in the middle of executing a
codebehind procedure. The Response is sent only when the Page is done
executing.

One solution would be to have an extra "ShowMessage.aspx". Redirect to
there, after setting some Session variables (message to show, URL to
redirect to after that).
The user sees that message and might click an "OK' button that will
redirect him to the next page you want to send him to.

Hans Kesting
 
B

bruce barker

then ExitPage() must be removing the alert, either by clearing the
content, doing a redirect or server transfer. remember the page
processing is just building html that will be sent to the browser after
its build. the only way to the alert appear before the exitpage code
runs unless you put the code on the next request.

-- bruce (sqlwork.com)
 
M

Miguel Gómez

Hi again, guys

Your comments have been of a great help for me.

Thanks to all of you.
"Miguel Gómez" <[email protected]> escribió en el mensaje de noticias:[email protected]...
Hi guys:

Please take a look to the following code:

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" + ex.Message.ToString() + "')</script>");

this.ExitPage();
}


The code's behaviour is that the "ExitPage()" procedure is executed, but the alert message does not show.

If I comment the call to the "ExitPage()" procedure , then the alert message is shown pretty well.

try
{...}
catch (Exception ex)
{
Response.Write("<script languaje=javascript>alert ('" + ex.Message.ToString() + "')</script>");

//this.SalirDelaPagina();
}

What I need is that the alert message shows, and then the "ExitPage()" procedure executes in order to exit the page correctly.

Any suggestion, please??

I'm becoming crazy.

Thanks to all.

Miguel
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top