Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirecting to another form on Post 1

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
<br>I have the following code. Basically it is a Comments.asp for users to leave messages.<br>I want to automatically send user to another page when the button is clicked to post button. (after the comment is added to the Access back end?)<br><br>Is this possible? Where do I put the redirect in my syntax, since I have to post to comments.asp to add the users comment.<br><br>Thanks<br>Ross<br><br>&lt;%ACTION = Request.Form(&quot;ACTION&quot;) <br>&nbsp;If ACTION = &quot;Save&quot; Then %&gt;<br>&lt;p&gt;&lt;!--#INCLUDE FILE=&quot;savemessage.asp&quot;--&gt;&lt;/p&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;&lt;% If ACTION = &quot;Save&quot; Then <br>End If <br><br><br>a bit later on..<br><br>&lt;form method=&quot;POST&quot; action=&quot;Comments.asp&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;style=&quot;border: medium none&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input type=&quot;hidden&quot; name=&quot;ACTION&quot; value=&quot;Save&quot;&gt;&lt;<br><br>&nbsp;End If %&gt;
 
Dear Ross,<br><br>You can use redirection I suppose, but I would stay away from it if at all possible.<br><br>One different idea is to point the form (ACTION=&quot;mypage.asp&quot;) to the page you want them to go to and put this:<br><br>&lt;%ACTION = Request.Form(&quot;ACTION&quot;) <br>&nbsp;If ACTION = &quot;Save&quot; Then %&gt;<br>&lt;p&gt;&lt;!--#INCLUDE FILE=&quot;savemessage.asp&quot;--&gt;&lt;/p&gt;<br><br>in the target page.<br><br>Good luck<br>-pete
 
But what if other pages also have links that go to this target page?<br><br>Would this code work in such circumstances.<br><br>Regards<br><br>Ross
 
Ross,<br>&nbsp;&nbsp;&nbsp;If you want to redirect the user to another page, in comments.asp,&nbsp;&nbsp;just add<br>response.redirect &quot;theotherpage.asp&quot;<br>after you write to the database.<br><br>Have you solved your hyperlinks problem? <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
The hyperlinks problem is still alive and kicking.<br><br>(if you are referring to the one where I have a table, but want to be able to move to the same page, no matter what hyperlink is chosen, taking a field on the row where teh hyperlink is clicked as a variable into the page.<br><br>Thanks as always,<br>Ross
 
Nick, <br>I get this when i do what you say.<br>&nbsp;<br><br>Response object error 'ASP 0156 : 80004005' <br><br>Header Error <br><br>/cgi-bin/test/rmclanac/savemessage.asp, line 38 <br><br>The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content. <br>&nbsp;<br>
 
Yep, that's the one I was referring to.&nbsp;&nbsp;I haven't answered your post, because the answer isn't that straightforward, and involves SQL and Javascript as well as VBscript/ASP.<br>I'll try to find the time this weekend to help you out.<br><br>By the way,&nbsp;&nbsp;I'd strongly advise checking out the tek-tips vbscript and javascript forums.&nbsp;&nbsp;There's a lot of great stuff there that you're missing that will help you immensely as a web developer. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Nick,<br>Regardiing the comments, where I want to move to a new page after a comment has been posted by a user. <br><br>Is there no properties like AfterUpdate, OnChange etc? (I am an Access developer at heart I'm afraid!)<br><br>Incidentally, is tek-tips your site? If not, you should really be charging for your services!<br>Either way, your help is always much appreciated.<br><br>Oh yes, it seems a bit strange that I am now third top TipMaster on the back of me posting questions here so much! I think I have only actually answered about three peoples questions in here to date!<br><br>Thanks again<br>Ross<br>
 
No, Ross, I'm not associated with Tek-Tips in any way.&nbsp;&nbsp;I'm just a member like you. In the past,&nbsp;&nbsp;I've gotten a lot of help from more experienced programmers, although in those days there was no such thing as the web.&nbsp;&nbsp;I used Compuserve (when it was $12 an hour at 300 baud) and BBS's. (I guess I'm dating myself here).&nbsp;&nbsp;8^)<br><br>I'm just trying to give something back.<br><br>ASP doesn't have the event model that Access or VB has.&nbsp;&nbsp;You just have to approach projects with a different frame of mind.<br><br><br> <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
Dear Ross,<br><br>You asked:<br><br>&gt;But what if other pages also have links that go to this target page?<br><br>&gt;Would this code work in such circumstances.<br><br>Yes it would if the other pages are not submitting a form to the target, in that case the condition:<br><br>&lt;%ACTION = Request.Form(&quot;ACTION&quot;) <br>&nbsp;If ACTION = &quot;Save&quot; Then %&gt;<br><br>would evaluate to 'false'<br><br>The problem with using redirection is that it is implemented with a round trip. It's just a performance issue, if your not concerned about it then it's no big deal.<br><br>Good luck<br>-pete
 
Dear Ross,<br><br>At the starting of the file you should add <br>response.buffer = true<br><br>So the there is non question of the error that the html headers were written to the browser<br><br>Or you can use javascript <br>i.e.<br>&nbsp;&nbsp;&nbsp;&nbsp;Response.write (&quot;&lt;script language='JavaScript'&gt;&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Response.write (&quot;window.location.href='fd_fr.htm';&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;Response.write (&quot;&lt;/script&gt;&quot;)<br><br>Enjoy <br><A HREF="mailto:webmaster@tripmedia.com">webmaster@tripmedia.com</A>
 
Be sure that you haven't written any page content (either straight HTML or response.write statements) BEFORE the redirect statement.<br><br>this will give you an error:<br><br>&lt;html&gt;<br>&lt;head&gt;&lt;/head&gt;<br>&lt;%<br>response.write(&quot;hello&quot;)<br>if request(&quot;x&quot;) &lt;&gt; 0 then<br>    response.redirect(&quot;thenextpage.asp?var=edit&quot;)<br>end if <br>%&gt;<br>...<br><br>this won't:<br><br>&lt;%<br>if request(&quot;x&quot;) &lt;&gt; 0 then<br>    response.redirect(&quot;thenextpage.asp?var=edit&quot;)<br>end if<br>%&gt;<br><br>&lt;html&gt;<br>&lt;head&gt;&lt;/head&gt;<br>&lt;%<br>response.write(&quot;hello&quot;)<br>%&gt;<br>...<br>
 
I HAVE SOLVED THIS PROBLEM USING NICKS SOLUTION (cheers)<br><br>Thanks for all your assistance on this one.<br><br>Ross<br><br>PS Nick - I see a HD jacket is winging its way towards you - congrats!
 
Well,&nbsp;&nbsp;not a jacket (yet).&nbsp;&nbsp;Just a chance to win it. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
The header problem is solved if you will set up <br><br>response.buffer = true<br><br>then the header problem is solved<br><br><A HREF="mailto:webmaster@tripmedia.com">webmaster@tripmedia.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top