473,503 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I want the alert button to appear

375 Contributor
Hi,

I have a page called as registration page. I want to check , if the person is already logged in, then this page should not be displayed.
I want a alert box to appear and then to be redirected to other page.

I wrote the following code

Expand|Select|Wrap|Line Numbers
  1.    string AlertScript = "";
  2.             AlertScript = "<script language='javascript'>alert('You are already Logged In');</script>";
  3.             Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", AlertScript);
  4.             //Response.Redirect("index.aspx");
What happens is when I uncomment the last line, it directly moves to the page, without the alert box appearing.

What should I do , so that the alert box appears and then move to the next page.

Regards
cmrhema
Jun 17 '09 #1
3 1665
Frinavale
9,735 Recognized Expert Moderator Expert
Your Response.Redirect is sending a header to the web browser indicating that the web browser should make a request to the "index.aspx" instead of the "registration.aspx" page. When the browser reads this header it redirects the user instantly to the proper page. The JavaScript never gets the chance to load.

Instead of displaying the JavaScript message in the registration page, consider displaying it on the index page instead.
Jun 17 '09 #2
Bassem
344 Contributor
Hello,
Beside Frinny idea I've a little one. See this!
Jun 17 '09 #3
Frinavale
9,735 Recognized Expert Moderator Expert
@Bassem
Originally I was going to recommend that the OP should consider using an HTTP redirect instead of using Response.Redirect.

Here's an example of an HTML Redirect:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.     <meta http-equiv="REFRESH" content="2; url=http://www.the-page-you-want-to-redirect-to.com">
  3. </head>
The above code will display the page for 2 seconds (content="2) before redirecting the user.

I just wasn't sure if the JavaScript Alert would prevent the page from redirecting......it may cause stop the redirect until the user clicks ok (and then it might not redirect).

I'm not sure how it would work so I didn't recommend it.
Jun 17 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1664
by: Ali | last post by:
Hello! I am trying make a alert message in an asp.net application, but i ned that the button tha appear into the message change the languaje depending the user. Anybody know hoe i can do that? ...
1
3434
by: Richard \(MrBonus\) | last post by:
the code is taken from my asp.net page. (written in C#) Hi, im trying to make my page postback before the it unloads, i've tried a lot of stuff, and finally I made something that worked, the...
6
3127
by: bonehead | last post by:
Greetings, I'm working on an e-mail form (btw many thanks to Philip Ronan for the very cool email address format tester function, best I've seen so far). I've been trying, with limited...
3
9615
by: umdsasha | last post by:
So, basically, I need to detect whether an alert window was thrown. I can't find where it's thrown from but I need to disable a button only if there were no alert windows thrown. Any ideas? ...
2
43256
by: jrsjrs | last post by:
The "filetest.txt" contents is here .................. one/yes two/no three/maybe four/fun five/ok ................ The main program is here
3
1399
Ajm113
by: Ajm113 | last post by:
Ok for some reason after the update of Firefox it seems that my form keeps getting submitted when the user made a error on the form. I just want the page to reload so the user may try again. Because...
2
2565
by: helraizer1 | last post by:
Hi folks, I have this site and idea http://www.helraizer.co.uk/mychatbox/ at the moment I'm using javascript to alert the user if they haven't entered a username or message but all this does is...
2
2462
by: Jonathan N. Little | last post by:
As part of a JavaScript precheck form validation I noticed a problem with trying to return focus to the field with an error. I have setup a demo page. ...
2
1102
by: axapta | last post by:
Hi Guys, I'm using this code in my asp.net page. It runs from a button webcontrol. Dim sbJScript As String sbJScript = "<script language = ""javascript"">" sbJScript = sbJScript &...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5576
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5005
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4670
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.