PDA

View Full Version : HTTP error after passing through form and using redirect method


scriptblur
09-19-2002, 08:06 AM
Hi guys..... I have a problem that kept troubling me... can any one please help... Thank you..

This error kept pestering me.....
It about the response.redirect method after i had pass some value from the list box.

Response object error 'ASP 0156 : 80004005'

Header Error

/sze_sean/html/try.asp, line 18

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.


My programs are:
<% @ Language=VBScript %>
<% Option Explicit %>

<html>
<head></head>
<body>
<form method=post action="try.asp">
<input type= text name=text1>
<br>
<input type= text name=text2>
<input type=submit value=submit>
<p>
<p>
<select name=default>
<option value"">weeks
<option value"">----------
<option value=week1>week1
<option value=week2>week2
<option value=week3>week3
<option value=week4>week4
<option value=week5>week5
<option value=week6>week6
<option value=week7>week7
<option value=week8>week8
</select>
</form>
<form method= post action="try.asp">
<select name=friend>
<option value"">men
<option value"">----------
<option value="ad_login.asp">nono
<option value="ad_login.asp">momo
</select>
<input type=submit value=go>
</form>
</body>
</html>



<% @ Language=VBScript %>
<% Option Explicit %>
<%
Dim strname1, strname2

strname1 = Request.QueryString("text1")
strname2 = Request.QueryString("text2")

response.write " textbox1 =" & strname1
response.write "<br> textbox2 =" & strname2

Dim idefault
idefault = Request("default")
response.write "<br> the week you have chosen is " &idefault

Dim ifriend
ifriend = Request("friend")
response.redirect ifriend
%>
:confused:

Alekz
09-19-2002, 08:31 AM
Hi,
You can not 'Redirect' after writing something else to the client...

response.write " textbox1 =" & strname1
response.write "<br> textbox2 =" & strname2
response.redirect

That's not possible and even if You could do this the effect will be that the user will see Your page for a very short time (maybe under 1 second) and the will be redirected...

If You want to keep the page for some seconds and then redirect to another page, do this client side.
<html>
<head>
<script language="JavaScript">
function redirect(url){
document.location = url;
}
</script>
</head>
<body onload="javascript: setTimeout(redirect('<%=redirectURL%>'),2000)">
2000 is 2000 miliseconds = 2 seconds.
</body>
</html>

Alex

scriptblur
09-19-2002, 08:41 AM
ok thank.. alex...