Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Show Alert Box and then Redirect

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kuldeep - 31 Oct 2007 13:19 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.