Forums
This topic is locked
redirect after insert
Posted 21 Jan 2002 15:57:16
1
has voted
21 Jan 2002 15:57:16 Andrew Ross posted:
This must be a simple thing, but I can't seem to find the answer anywhere. I have two insert pages (as discussed in the topic "multiple insert". The first page uses the standard UD insert behaviour to place records into my Contacts table. I've used the redirect option of the behaviour to redirect to page 2 after insert. On page 2 I have used a command to insert multiple records into my ContactCategories table.The problem is, after insert page 2 reloads itself. I want it to redirect to another page that gives the option to add another record or move on to another part of the site.
Replies
Replied 21 Jan 2002 17:09:20
21 Jan 2002 17:09:20 Viktor Farcic replied:
Just insert following code after 'Command':
<% Response.Redirect("WhateverPage.asp" %>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
This must be a simple thing, but I can't seem to find the answer anywhere. I have two insert pages (as discussed in the topic "multiple insert". The first page uses the standard UD insert behaviour to place records into my Contacts table. I've used the redirect option of the behaviour to redirect to page 2 after insert. On page 2 I have used a command to insert multiple records into my ContactCategories table.
The problem is, after insert page 2 reloads itself. I want it to redirect to another page that gives the option to add another record or move on to another part of the site.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
<% Response.Redirect("WhateverPage.asp" %>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
This must be a simple thing, but I can't seem to find the answer anywhere. I have two insert pages (as discussed in the topic "multiple insert". The first page uses the standard UD insert behaviour to place records into my Contacts table. I've used the redirect option of the behaviour to redirect to page 2 after insert. On page 2 I have used a command to insert multiple records into my ContactCategories table.
The problem is, after insert page 2 reloads itself. I want it to redirect to another page that gives the option to add another record or move on to another part of the site.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
Replied 22 Jan 2002 02:26:15
22 Jan 2002 02:26:15 Andrew Ross replied:
Thanks for the reply, but after inserting the code I received this error:
"Response object error 'ASP 0156 : 80004005'
Header Error
/canphotodirect/insert_pg2.asp, line 104
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content."
Here is my code. I tried several variations and they all returned the same error.
<%
If Request("chkCategories" & (rsCategories.Fields.Item("Category_ID".Value)) <> "" Then
set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_canphoto_STRING
Command1.CommandText = "INSERT INTO ContactCategories (Category_ID, Contact_ID) VALUES (" + Replace(Command1__varCategories, "'", "''" + ", " + Replace(Command1__varContact_ID, "'", "''" + " "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
End If
%>
line 104 <% Response.Redirect("insert_pg3.asp" %>
"Response object error 'ASP 0156 : 80004005'
Header Error
/canphotodirect/insert_pg2.asp, line 104
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content."
Here is my code. I tried several variations and they all returned the same error.
<%
If Request("chkCategories" & (rsCategories.Fields.Item("Category_ID".Value)) <> "" Then
set Command1 = Server.CreateObject("ADODB.Command"
Command1.ActiveConnection = MM_canphoto_STRING
Command1.CommandText = "INSERT INTO ContactCategories (Category_ID, Contact_ID) VALUES (" + Replace(Command1__varCategories, "'", "''" + ", " + Replace(Command1__varContact_ID, "'", "''" + " "
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()
End If
%>
line 104 <% Response.Redirect("insert_pg3.asp" %>
Replied 22 Jan 2002 02:31:34
22 Jan 2002 02:31:34 Andrew Ross replied:
I just discovered that you can't add <% response.redirect("page.asp" %> within the body tags of a page or you will get the error above. That's where I had to put it, because my command is within the repeat region of my page.
After much trial and error it looks like this bit of code after the repeat region does the trick.
<%
If Request.Form("Submit2" = "Insert Data" Then
Response.Redirect("insert_pg3.asp"
End If
%>
"Submit2" is the name of the submit button in my form and "Insert Data" is the value.
Cheers
<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Edited by - arossphoto on 22 Jan 2002 04:31:59
After much trial and error it looks like this bit of code after the repeat region does the trick.
<%
If Request.Form("Submit2" = "Insert Data" Then
Response.Redirect("insert_pg3.asp"
End If
%>
"Submit2" is the name of the submit button in my form and "Insert Data" is the value.
Cheers
<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Edited by - arossphoto on 22 Jan 2002 04:31:59
Replied 22 Jan 2002 09:26:54
22 Jan 2002 09:26:54 Viktor Farcic replied:
I tought that 'command' code is before '<html>'. Anyway, I'm glad you've found the solution.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I just discovered that you can't add <% response.redirect("page.asp" %> within the body tags of a page or you will get the error above. That's where I had to put it, because my command is within the repeat region of my page.
After much trial and error it looks like this bit of code after the repeat region does the trick.
<%
If Request.Form("Submit2" = "Insert Data" Then
Response.Redirect("insert_pg3.asp"
End If
%>
"Submit2" is the name of the submit button in my form and "Insert Data" is the value.
Cheers
<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Edited by - arossphoto on 22 Jan 2002 04:31:59
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I just discovered that you can't add <% response.redirect("page.asp" %> within the body tags of a page or you will get the error above. That's where I had to put it, because my command is within the repeat region of my page.
After much trial and error it looks like this bit of code after the repeat region does the trick.
<%
If Request.Form("Submit2" = "Insert Data" Then
Response.Redirect("insert_pg3.asp"
End If
%>
"Submit2" is the name of the submit button in my form and "Insert Data" is the value.
Cheers
<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
Edited by - arossphoto on 22 Jan 2002 04:31:59
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Viktor Farcic
TalkZone Manager