Home All Groups Group Topic Archive Search About

MessageBox not showing before Response.Redirect

Author
21 Apr 2005 9:37 AM
Xarky
Hi,
I am showing a messagebox with the following method:

public static void ShowMessageBox(HtmlTextWriter htmlTextWriter,
string message)
{           
    htmlTextWriter.Write("<script
language=JavaScript>window.alert('"+message+"');</script>");
    htmlTextWriter.Flush();
} // end method showMessageBox


Now I am calling it with the following way:

HtmlTextWriter htmlTextWriter;
htmlTextWriter = this.CreateHtmlTextWriter(Context.Response.Output);   
ShowMessageBox(htmlTextWriter, "Hello.");

When I add Response.Redirect(...), message box is not being shown
while when I do not set Respones.Redirect, it works.

Is there a way how I can solve this problem.
Thanks in Advance

Author
21 Apr 2005 12:33 PM
Elton W
Hi Xarky,

In order to show message box then redirect to other page,
you should use client-side redirect rather than server-
side Redirect (Response.Redirect).

For example,

RegisterStartupScript("redirect", "<script
language=JavaScript>alert('Message'); open
('http://www.yahoo.com');</script>")

Show Message first. Once click OK it opens yahoo page in
new window. If you want to keep new page in same window,
you need more javascript code.

HTH

Elton Wang
elton_W***@hotmail.com



>-----Original Message-----
>Hi,
>I am showing a messagebox with the following method:
>
>public static void ShowMessageBox(HtmlTextWriter
htmlTextWriter,
>string message)
>{           
>    htmlTextWriter.Write("<script
>language=JavaScript>window.alert
('"+message+"');</script>");
>    htmlTextWriter.Flush();
>} // end method showMessageBox
>
>
>Now I am calling it with the following way:
>
>HtmlTextWriter htmlTextWriter;
>htmlTextWriter = this.CreateHtmlTextWriter
(Context.Response.Output);   
Show quoteHide quote
>ShowMessageBox(htmlTextWriter, "Hello.");
>
>When I add Response.Redirect(...), message box is not
being shown
>while when I do not set Respones.Redirect, it works.
>
>Is there a way how I can solve this problem.
>Thanks in Advance
>.
>
Author
22 Apr 2005 12:13 PM
xarky d_best
Hi,
I require to open the new page in the same window.


*** Sent via Developersdex http://www.developersdex.com ***