Which option is best

L

Luis

I have 2 asp pages, Page1.asp and Page2.asp. Page2 is a "printable"
version of Page1 and it contains the same information as Page1.

When Page1 is loaded in the browser it connects to a database and
retrieves some information which is used to do some calculations and
to display some data on this page. At the bottom of the page is a
'Print' button. When the user clicks this button it opens Page2 in a
new window and displays the same data in a format that can be printed.

Which is the best way to get the information from Page1 to Page2:

1. Using hidden fields on Page1.asp
2. Using session variables
3. Connecting to the database on Page2 and retrieving the information
again.

I'm considering option 1, creating form with hidden fields on Page1
that will contain the values that are required on Page2 and posting
that form to Page2.

Page2 will contian code such as:

dim Temp1, Temp2
Temp1 = Request.Form("Field1Name")
Temp2 = Request.Form("Field2Name")

for each of the fields on Page1. The data will be displayed on this
print-friendly page using code similar to:

Field One: <%=Temp1%>
Field Two: <%=Temp2%>

Is this the right approach, or would I be better off using one of the
other approaches (session varibles or retrieving the data from the
datbase again)?
 
A

Aaron Bertrand - MVP

I have 2 asp pages, Page1.asp and Page2.asp. Page2 is a "printable"
version of Page1 and it contains the same information as Page1.

Why do you have separate pages for this? Did you know that you can use
style sheets to hide certain elements, change sizes, colors, etc. so that
any page can become a printer friendly page without taking away from the
on-screen prettiness? (http://www.w3.org/TR/REC-CSS2/media.html)

I'm working on a new version of aspfaq.com and you'll probably be amazed at
the contrast between on-screen and printed versions of the same article.

This dual-page maintenance thing is for the birds... it reminds me of the
days when we used to make a Netscape page, and an IE page...

A
 
D

dlbjr

I concur. use the css solution. No round trip needed.

-dlbjr

Discerning resolutions for the alms
 
B

Bullschmidt

I'd vote for option 3:
<<
3. Connecting to the database on Page2 and retrieving the information
again.
Best regards,
J. Paul Schmidt, Freelance ASP Web Developer
http://www.Bullschmidt.com
ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...
 
L

Luis

Bullschmidt said:
I'd vote for option 3:

3. Connecting to the database on Page2 and retrieving the information
again.


Isn't option 3 more "resource intensive" and "slower" since it does
involve another trip to the server to connect to the database?

The CSS approach that Aaron suggested does sound like a really good
approach that I hadn't thought of.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top