Framework: Visual Studio 2005
Technology: ASP.NET 2.0
Language: C#.NET 2.0
Hi All,
I have an event procedure as shown below.
protected void lnkBtSendEmail_Click(object sender, EventArgs e)
{
FillVariables();
GenerateDataShuttle();
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script
language='JavaScript'>alert(ABCDEFGH');</script>");
Response.Redirect("Default.aspx");
}
This piece of code will not allow the Javascript function to show the
"Alert" box to pop-up. The reason being, there is a Response.Redirect
happening soon after the ClientScript.RegisterStartupScript.
Now, if I comment the Response.Redirect line, the alert box pops up and
shows up the message (ABCDEFGH).
How do I show the Alert Box first and then redirect to any page?
Thanks in advance,
Kuldeep
Aidy - 31 Oct 2007 13:26 GMT
You need to do the redirect in your javascript also.
alert ('ABCDEFGH'); window.location.href = 'newpage.aspx';
> Framework: Visual Studio 2005
> Technology: ASP.NET 2.0
[quoted text clipped - 31 lines]
>
> Kuldeep
Kuldeep - 31 Oct 2007 13:34 GMT
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script
language='JavaScript'>alert('ABCDEFGH'); window.location.href =
'Default.aspx';</script>");
Oops that should work!
> Framework: Visual Studio 2005
> Technology: ASP.NET 2.0
[quoted text clipped - 31 lines]
>
> Kuldeep
Mark Rae [MVP] - 31 Oct 2007 13:39 GMT
> ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script
> language='JavaScript'>alert('ABCDEFGH'); window.location.href =
> 'Default.aspx';</script>");
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
"alert('ABCDEFGH'); window.location.href = 'Default.aspx';", true);
Then you don't need to worry about using deprecated <script> tags...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net