Alert message not shown

  • Thread starter Thread starter Miguel Gómez
  • Start date Start date
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
 
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
 
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)
 
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
 
Back
Top