473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Alert box doesn't appear

Jan
Hi,

Why don't i see the Alert box? The page is redirected without showing it. I
also tried with parameter 'False' and 'True'.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert(this is ok);" _
& "</script>"
Response.Write(jv)
Response.Redirect(next.aspx")
'Response.Redirect(next.aspx", False)
'Response.Redirect(next.aspx", True)
End If
End Sub

Thanks
Jan
Mar 7 '07 #1
6 2573
"Jan" <cbcbc@xcvxwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
& " alert(this is ok);" _
& " alert('this is ok');" _

Mar 7 '07 #2
Jan
Yes you're right, wrong copy of code, but that's not the problem.
In my code, there are quotes and i can't see the Alert box (without quotes,
i would get a java-error).
If i suppress the line with : " Response.Redirect(next.aspx")", i see that
Alert box ...

Why not with the Response.redirect?
(i tried with server.transfer and this works!)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert('this is ok');" _
& "</script>"
Response.Write(jv)
Response.Redirect(next.aspx")
'Response.Redirect(next.aspx", False)
'Response.Redirect(next.aspx", True)
End If
End Sub

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:%2***************@TK2MSFTNGP02.phx.gbl...
"Jan" <cbcbc@xcvxwrote in message
news:u1**************@TK2MSFTNGP06.phx.gbl...
> & " alert(this is ok);" _
& " alert('this is ok');" _

Mar 7 '07 #3
On Mar 7, 8:42 pm, "Jan" <cbcbc@xcvxwrote:
Hi,

Why don't i see the Alert box? The page is redirected without showing it. I
also tried with parameter 'False' and 'True'.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert(this is ok);" _
& "</script>"
Response.Write(jv)
Response.Redirect(next.aspx")
'Response.Redirect(next.aspx", False)
'Response.Redirect(next.aspx", True)
End If
End Sub

Thanks
Jan
Okay,

When you send a normal GET/POST request to a server, it generates a
response which consists of headers and content. Part of the headers
for a normal response it a status code - 200. This tells the browser
that the response is normal, and that it should go ahead and use the
rest of the headers and the content to display the page to the user.

When you use Response.Redirect on the server, it changes that status
code that is sent back to the client to 302. This status code,
essentially, says "what you were asking for has temporarily moved to
this new location", and provides the location information (in this
case, next.aspx). The browser just goes right ahead and requests the
next page - it never receives/processes and content associated with
the old page.

If you want to have a message box and then navigate to the next page,
you can put the navigation step into the javascript. Just add
window.navigate('next.aspx') to your script.

Damien

Mar 8 '07 #4
"Jan" <cbcbc@xcvxwrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
Why not with the Response.redirect?
Apologies - I didn't read your post properly...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert('this is ok');window.location='next.aspx';" _
& "</script>"
Response.Write(jv)
End If
End Sub
Mar 8 '07 #5
Jan
Thnaks Mark, i knew that.

What i don't know is why it doesn't work with response.redirect? Is there a
specific reason for that?
As i said, it works also with Server.transfer ...Why?
Thanks
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:uZ**************@TK2MSFTNGP04.phx.gbl...
"Jan" <cbcbc@xcvxwrote in message
news:uB**************@TK2MSFTNGP06.phx.gbl...
>Why not with the Response.redirect?

Apologies - I didn't read your post properly...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert('this is ok');window.location='next.aspx';" _
& "</script>"
Response.Write(jv)
End If
End Sub


Mar 8 '07 #6
Jan
Ok thanks for explantion

"Damien" <Da*******************@hotmail.comschreef in bericht
news:11**********************@8g2000cwh.googlegrou ps.com...
On Mar 7, 8:42 pm, "Jan" <cbcbc@xcvxwrote:
>Hi,

Why don't i see the Alert box? The page is redirected without showing it.
I
also tried with parameter 'False' and 'True'.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Me.Load
Dim a As Integer
a = 5
If a = 5 Then
Dim jv As String
jv = "<script language='javascript'>" _
& " alert(this is ok);" _
& "</script>"
Response.Write(jv)
Response.Redirect(next.aspx")
'Response.Redirect(next.aspx", False)
'Response.Redirect(next.aspx", True)
End If
End Sub

Thanks
Jan

Okay,

When you send a normal GET/POST request to a server, it generates a
response which consists of headers and content. Part of the headers
for a normal response it a status code - 200. This tells the browser
that the response is normal, and that it should go ahead and use the
rest of the headers and the content to display the page to the user.

When you use Response.Redirect on the server, it changes that status
code that is sent back to the client to 302. This status code,
essentially, says "what you were asking for has temporarily moved to
this new location", and provides the location information (in this
case, next.aspx). The browser just goes right ahead and requests the
next page - it never receives/processes and content associated with
the old page.

If you want to have a message box and then navigate to the next page,
you can put the navigation step into the javascript. Just add
window.navigate('next.aspx') to your script.

Damien

Mar 8 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: schieco | last post by:
The following code always prints the debug lines inside the conditional if statement before and after the alert statement when the session has timed out, but the alert and redirect only appear/work...
2
by: Robert Nurse | last post by:
Hi All, I've got a strange problem in IE that I wonder if anyone has seen before. Basically, I've got a two window scenario. The parent window opens the child via window.open(). The child...
11
by: Alistair Saldanha | last post by:
I'm looking for the event that is fired by Internet Explorer to an "alert": <SCRIPT> Alert("You already have a session open") </SCRIPT> The event would be webBrowser.Document.???? Much...
1
by: petes | last post by:
How does one center text in an alert box? and how do you make the alert box appear in the middle of the screen? I've seen it done, but my alerts have text left justified, and the box is longer than...
6
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...
9
by: Tonio Tanzi | last post by:
I have an asp page with this tag <body onLoad="show_msg('<%=error_msg%>');"> where "show_msg" is a javascript function that shows the message contained in the asp variable "error_msg" only if...
2
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
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 &...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.