PDA

Click to See Complete Forum and Search --> : Redirect


gsc1ugs
Feb 7th, 2001, 11:05 AM
This is doing my head in....
how do i redirect after updating a database to see latest entries

code: extract

FOR i = 1 to RSAddrecord.Fields.Count -1
'RS.Fields(i).Value = RS.Fields(i).Name
if(RSAddrecord.Fields(i).Name <>"ID" ) then
RSAddrecord.Fields(i).Value = Request.Form(RSAddrecord.Fields(i).Name)
end if
if(RSAddrecord.fields(i).Name = "date") then
RSAddrecord.Fields(i).Value = Now()
end if
NEXT
RSAddrecord.Update
end if
RSAddrecord.Close
GobjConnect.Close
Update = 1
session("update") = Update
End Sub

Response.Write "</table>"
Response.Write "<a href=default.asp?mode=1>Login</a>"

Response.Write "</body>"
Response.Write "</html>"
If session("update") = 1 then
Response.Redirect("default.asp") /// i get waring that headers are already written
end if
%>


Many thanks

JoshT
Feb 7th, 2001, 12:26 PM
Response.Redirect must be called before any Response.Write's.

Josh

Feb 7th, 2001, 12:30 PM
Do you know Any Javascript. If you do you can put a hidden text box in the page. When the page first loads have it set to 0 and when you have updated change it to 1.
Put a JavaScript event on the hidden field and when it's changed run this script:
{
document.location = "www.mypage.com"
}

that's probably not much use, I took pity on you not having any replies. :D

gsc1ugs
Feb 8th, 2001, 04:20 AM
The Repsonse.redirect is called before the repsonse.write's, this is the last event of the page...

Any help Ian?? seems your the man

Kagey
Feb 8th, 2001, 02:13 PM
put Response.Clear right before the response.redirect. that should do the trick mate.

gsc1ugs
Feb 9th, 2001, 05:14 AM
Got this message

Response object error 'ASP 0159 : 80004005'

Buffering Off

/comp/default.asp, line 256

Buffering must be on.

gsc1ugs
Feb 9th, 2001, 06:27 AM
Put at the start this
response.buffer = true

seems to whirl away and do nowt..