Forums

ASP

This topic is locked

Update and Redirect to previous page

Posted 20 Mar 2007 03:56:27
1
has voted
20 Mar 2007 03:56:27 Javier Castro posted:
Hi Guys,

I have a page with a list of Newsletter Issues each one with different value. Each item on that list links to a page that based on each id, show the articles for each issue. each article title links to an Edit page with an Update form. The update works. My problem is:

Once the update has occurred then, I want to go back to the list of articles to edit another article. but I can't since the Newsletter Id is gone and don't know how to append it to the redirect part of the Update function.

Example:

Newsletter#1 has an id=9 --->Links to Articles from Newsletter 1. lets say 3 articles with ids ranging from 1 to 3. ---> I click on article 3 with an id=3 then I make a change on the record, press submit and the redirect goes back to the list of articles of Newsletter#1 with Id = 9.

Any help will be much appreciated.

Javier

"I'm a very slow learner and I forget fast"
Grandpa <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Replies

Replied 20 Mar 2007 12:41:31
20 Mar 2007 12:41:31 Lee Diggins replied:
Hi Javier

If you setup and passed your name/value pairs correctly in the querystring from the first page, making sure each name/value pair name is unique then this should work out of the box. As long as you are passing the querystring correctly to the update page, all items in your querystring will be automatically appended to the redirect page url and presented back to that page.

If I remember rightly you had a thread about this, so maybe a rethink of the name/value pair in the first page and the way you handle that passed querystring on the second page would resolve this. Remember you had ID for both pages in the querystring.

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 20 Mar 2007 13:38:41
20 Mar 2007 13:38:41 Javier Castro replied:
Thanks Lee. I'll do as you suggest. Is there a tutorial or book that has this subject of passing values that perhaps you can recommend. I looked on google, but I didn't find anything clear enough. think I need a reference book for my tiny mind.

Thanks again.

Javier
Replied 20 Mar 2007 16:26:50
20 Mar 2007 16:26:50 Lee Diggins replied:
Hi Javier

I've not heard of anything, that doesn't mean it doesn't exist somewhere. Just post back here if you've any questions and I'll help where I can.

How many pages are you using in this process, I'm thinking you're using 3?

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 20 Mar 2007 17:20:27
20 Mar 2007 17:20:27 Javier Castro replied:
yes Lee. I tried your previous suggestion but I don't seem to get it.

page 1 -List of Newsletter Issues(published) --&gt;i.e. Issue 1 with id=1 calls page 2 where the Articles of Issue 1 appear
page 2 -List of Articles Per Issue --&gt; here Articles of Newsletter 1 are linked to the Edit Form
page 3 -Edit form for each article ---&gt; from here, once the article is edited I want to return (Redirect) to the previous list where Articles from Issue 1 were available. Instead I keep going to the correct page but the id displayed on the URL corresponds to one of the articles and not to the Newsletter Issue 1.

It's driving me bonkers, to the point that I was thinking to open the dit from on a popup window that on submit it closes itself. However it's not my first choice.

Which page should I be working on? The form? the First page or the second page. I am scratching my head. I still have plenty of hair to scratch though.
Should I use your suggestion:
&lt;%
Dim passedID
passedID = Request.Querystring("issue"
%&gt;

any input will be appreciated regardless of the outcome.

Javier
Replied 20 Mar 2007 17:50:18
20 Mar 2007 17:50:18 Lee Diggins replied:
Hi Javier

This is failing because of the previous posting you had about getting values passed along pages via querystring. This can performed fairly easily with minimal amout of coding on page two.

Remember each of your name/value pairs used in any of your forms should have a unique names, at the moment you have Page 1 with field called ID and Page 2 with ID, because we worked on this previously.

Try this:

Page 1 form field nid (NewsLetterID). When submitted this will pass page2.asp?nid=value1
<b>ACTION</b>
Rename to nid

Page 2 form field aid (ArticleID). When submitted this will pass page3.asp?aid=value2&nid=value1
<b>ACTION</b>
Rename to aid
Change the recordset used to populate the articles to use the new nid name/value pair sent by Page 1.
Change the edit hyperlink that submits to Page 3 to include Request.ServerVariables("QUERY_STRING" to append the passed querystring to the newly created :
<pre id=code><font face=courier size=2 id=code>&lt;a href="page3.asp?aid=&lt;%=(Recordset1.Fields.Item("ArticleID".Value)%&gt;&&lt;%=Request.ServerVariables("QUERY_STRING"%&gt;"&gt;Edit&lt;/a&gt;</font id=code></pre id=code>
This generates page3.asp?aid=articleidvalue&nid=newsletteridvalue

Page 3 edit article for newsletter. Redirect to Page one with nid in querystring.
<b>ACTION</b>
Just make sure you fill in the redirect to page1.asp, the update behaviour will automatically take the querystring and append it to the redirect, so you'll end up with:
page1.asp?aid=articleidvalue&nid=newsletteridvalue
The aid value in the querystring will be ignored in page 1, so not to worry.

If you're stuck I can build a quick three page example for Northwind or Pubs if you want. Hopefully this'll get you going in the right direction.



Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
[Studio MX/MX2004 | ASP -&gt; VBScript/PerlScript/JavaScript | SQL | CSS ]

Edited by - Digga the Wolf on 20 Mar 2007 17:54:49
Replied 20 Mar 2007 18:03:51
20 Mar 2007 18:03:51 Javier Castro replied:
thanks.
OK. I'll keep going at it.
Replied 20 Mar 2007 19:07:42
20 Mar 2007 19:07:42 Javier Castro replied:
Partial success. For a moment thought, eureka!!!, but not. Just in the right Path.

The first part is great. However, there is a problem when we are redirected. If I want to edit another article, the previos query.string gets appended, so The Page to Specific Record doesn't work anymore.

i.e. /www.site.com/nl_item_editform.asp?aid=22&aid=23&nid=7 if it were /nl_item_editform.asp?aid=23&nid=7 it would work, but it seems that somewhere there is a problem.

Any thoughts?

Replied 20 Mar 2007 22:25:37
20 Mar 2007 22:25:37 Lee Diggins replied:
Hi Javier

Not sure I follow you. Somewhere you are adding aid twice to the querystring, once with a value of 22 and the next time with 23. Track this down eliminating the 22 value for aid and you've cracked it. Record the values passed from each page in the querystring. You must be calling page 3 with that combination aid=22&aid=23&nid=7

I've completed the Pubs samples, mail me if want them or chat via MSN or AOL.

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 21 Mar 2007 03:42:17
21 Mar 2007 03:42:17 Javier Castro replied:
After a few more hours working at this, and after reviewing your samples I figured out the problem.
I failed to create a recordset for the Newsletter issue where I was suppossed to use the
param
number
request.querystring('nid')
0

Then on the lik after the url, the first parameter was "aid" or aid=&lt;%=(rsNewsletter.Fields.Item("intNewsletterID".Value)%&gt;
and the second was: nid=&lt;%=(rsNewIssue.Fields.Item("intIssueID".Value)%&gt;"
Using the: &lt;%=(Request.ServerVariables("QUERY_STRING")%&gt; produced a kind of looping situation where after Editing on the 3rd page, I was redirected correctly to the 2nd page where the artcles were and with a strig like this: www.site.com/nl_item_editform.asp?aid=23&nid=7
So, if I tried to Edit another article, the Id of the article was added to the existing string, therefore braking the link to the specific records.

Thanks a lot Lee. You make a difference in this place that sometimes lacks responses. Sometimes it's all we need to keep learning, a little push.

Javier



Thanks for your support and your time.
Replied 21 Mar 2007 11:04:56
21 Mar 2007 11:04:56 Lee Diggins replied:
Hi Javier

You're welcome. Sometimes all it takes is a little perseverance, try and push aside the frustrations and see things clearer.

Thanks for your comments Javier, it doesn't hurt anyone to have manners and thank someone for providing or assisting in a solution.

Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
Replied 26 Mar 2007 15:59:56
26 Mar 2007 15:59:56 lou castro replied:
I am having the same issue as you Javier. I am glad you resolved it, but I as still foggy on it.
I have 3 pages also. The first page shows receiving documents,
page 2 shows details of each document.
page 3 is a ADD NEW DETAIL page. After inserting a new detail, I need to go back to page 2 with
the correct ID.

How can this be resolved?

Thanks "brother"
Replied 26 Mar 2007 18:48:05
26 Mar 2007 18:48:05 Javier Castro replied:
can you explain each page a little more?
Replied 26 Mar 2007 20:27:31
26 Mar 2007 20:27:31 lou castro replied:
ok...
Page 1 shows receiving documents, which includes delivery method, carrier, arrival date, etc. Primary key is RECID.
Page 2 shows details of each receiving documents, such as weight, box number, grade. It gets the
receiving document from page 1 (passes url "recID".
Example: receivingdetails.asp?recID=2

From page 2, you can add more details to this document. I can pass the recID to the add.asp page,
with a hidden field, and can successfully add new details.
page 3 is the add.asp page. I can add a record successfully, but after adding record,
I want ot go back to page 2 with the url parameter (receivingdetails.asp?recID=2). I can get it
to go to receivingdetails.asp, but without the url.

Thanks for taking a look.

Reply to this topic