Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Show Alert Box and then Redirect

Reply
Thread Tools

Show Alert Box and then Redirect

 
 
Kuldeep
Guest
Posts: n/a
 
      10-31-2007
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








 
Reply With Quote
 
 
 
 
Aidy
Guest
Posts: n/a
 
      10-31-2007
You need to do the redirect in your javascript also.

alert ('ABCDEFGH'); window.location.href = 'newpage.aspx';

"Kuldeep" <> wrote in message
news:...
> 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
>
>
>
>
>
>
>
>



 
Reply With Quote
 
 
 
 
Kuldeep
Guest
Posts: n/a
 
      10-31-2007
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script
language='JavaScript'>alert('ABCDEFGH'); window.location.href =
'Default.aspx';</script>");

Oops that should work!

"Kuldeep" <> wrote in message
news:...
> 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
>
>
>
>
>
>
>
>



 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      10-31-2007
"Kuldeep" <> wrote in message
news:...

> 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...


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

 
Reply With Quote
 
Tmkasp Tmkasp is offline
Junior Member
Join Date: Mar 2009
Posts: 1
 
      03-21-2009
As i am a beginner, u saved my time lot.. Thanks..
 
Reply With Quote
 
sun_kkd sun_kkd is offline
Junior Member
Join Date: Apr 2012
Posts: 1
 
      04-27-2012
The redirect is slow and takes a minute. Is there a way to load the redirect faster.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one play a .wav file and then another and then another...? ted.j.conway@gmail.com Javascript 4 01-17-2006 03:28 AM
Help. SessionID is x then y then x then y BodiKlamph@gmail.com ASP General 0 09-03-2005 03:02 PM
Alert box then close window BWGames Javascript 2 05-24-2004 02:43 AM
Basic Q - Response.Redirect, all redirect to first Response.Redirect statement Sal ASP .Net Web Controls 1 05-15-2004 03:46 PM
ALERT: Virus Scam Alert! Toronto Garage Door Company Computer Support 1 11-18-2003 04:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57