PDA

Click to See Complete Forum and Search --> : passing variables from on ASP to another


vbuser1976
Feb 12th, 2001, 12:32 PM
Hi everyone!

I hope you enloyed your weekend. My newbie questions is this:

If I assign data to a variable in one page using ASP/ADO, can I use that same variable(with the data) on another asp page? If so, is there any specific code I need to have/use?

I hope this question isn't confusing. Thanks in advance.

usejwat
Feb 12th, 2001, 03:40 PM
You can use hidden fields on a form and then use the Request.Form("fldID") (this is using a post on the form action) to get the values or you can pass it in the querystring using a get and then use the Request.Querystring("fldID"). If you want to use session variables I can't site code for you. I stay away from session variables due to scaleability, expiration and corruption issues.

vbuser1976
Feb 12th, 2001, 04:04 PM
Yeah, I kind of of guessed that. But, here's my problem:

I am running a search on a html form that jumps to an asp page with an HTML table with all the results. At the end of each row of records (sorted by ID) there are two links. The first link lets the user go to another ASP page to edit the record. The second link lets the user go to another ASP page (different than the first) to just view the entire record data. How do I go about doing this?

Thanks again in advance.

usejwat
Feb 12th, 2001, 04:26 PM
Maybe I have got it now. You have two Hyperlinks that you want to build dynamically based on some data. If this is correct I would go with the option of embedding the data you need to pass to either page in the URL. You do this by appending a question mark "?" and then as many ID=Value pairs as needed to deliver the data to the ASP Page. Here is an example

http:/some.url.com/yourpage.asp?Field1=Data1&Field2=Data2.

I do this exclusively in a site I wrote for an on-line Insurance quote engine. The reason I did this is because some pages did not use a form so I could not use hidden fields. I used a QueryString that I built at run-time and I found it quit easy to pass values around pages this way. The other benefit is that the solution is more scalable than if I used session variables, and I did not need to worry about session expiration either. If you would like an example take a look at the site HTTP://www.cycledirect.com. This will give you an example from the users’ perspective. If you would like I can send you some of the ASP code I used to generate this page.

I hope I am understanding your question and therefor responding with something that will help you. If not let me know and I can pursue another avenue with this. As you know IIS/ASP has about a 100 ways to solve the same problem.

Eclipse DevSoft
Feb 13th, 2001, 12:10 AM
The best way to go about this is to attached the record ID or pointer to your destination url as querystring and retrieve this id. Query the record and display/edit it. You don't even need a separate page for editing and viewing. You could pass a parameter for the mode (i.e. edit=0, edit=1)

example:
<a href="/editpage.asp?ID=yourrecordidhere">Edit</a>
<a href="/viewpage.asp?ID=yourrecordidhere">View</a>

Note that editpage and viewpage can be one page.

retrieve the record id by using the ff:
dim RecordID
RecordID = Request.QueryString("ID")

Your statement would be:
"SELECT * FROM MyTable WHERE RecordID = '" & RecordID & "'"

query it....display it....do as you please....

vbuser1976
Feb 14th, 2001, 07:30 AM
Thanks Eclipse & usejwat, that was what I was looking for.