473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Newby/Novice Question: Printing Web Pages...

Hello, I have a question for the group.

My current project uses multiple panels to display the contents of a
web page. The thing is many of these panels are hidden while only one
is visible at a time (much like tabs). I use a set of command buttons
to switch between these panels. What I would like to do is to create a
print function that will create a preview showing all panels in
sequential order which could be used to print a hard copy.

Any suggestions?

TIA...

Dec 19 '05 #1
6 1047
The simple answer is: Use CSS to do the dirty work

You can set up different stylesheets for screen and print (an example
to follow)

BUT:
It all depends on your app

Is all your data easily available upfront? is there a lot of overhead
involved in fecthing data to be displayed on the other "tab"s

Are your clients on a low latency connection to the server?

EXAMPLE:

<STYLE type="text/css">
@media print { .ScreenOnly { display: none; } }
@media screen { .PrintOnly { display: none; }
.TabContentHidden { display: none; visibility: hidden; } }
</STYLE>

<DIV class="ScreenOnly" >This content will not be printed</DIV>
<DIV class="PrintOnly" >This content will not be visible on screen, but
<B>will</B> be printed</DIV>
<DIV class="TabContentHidden" >This is an invisible panel (but will
print)</DIV><DIV class="TabContent" >This is the visible panel (both
print and screen)</DIV>
<DIV class="TabContentHidden" >This is an invisible panel (but will
print)</DIV>

The other advantage to this approach is that you can switch "tabs" on
the browser without the server roundtrips (read near-instantaneous)

Hope this helps
-- addup --

Dec 19 '05 #2
Hmmm.

That looks interesting and might work if I had things setup "normally"
but that approch wouldn't work, I think. I am using ASPdotNET (i.e.
postbacks) to make the different panels/DIVs visible or not. If a
panel is not set as visible by the server it doesn't even show up on
the client side.

Private Sub btnPg1_Click(sender as Object, e as EventArgs) Handles
btnPg1.Click
pnlPg1.Visible = True
pnlPg2.Visible = False
pnlPg3.Visible = False
pnlPg4.Visible = False
pnlPg5.Visible = False
End Sub

Is there perhaps more of a dotNET approach?

TIA...

I guess I should lookup more on that CSS stuff.

Dec 19 '05 #3
You will have to change from ASP.Net Visibility to CSS visiblity:

pnlPg1.Visible = true
pnlPg1.Attributes.Add("display", "");
pnlPg2.Visible = true
pnlPg2.Attributes.Add("display", "none");
pnlPg3.Visible = true
pnlPg3.Attributes.Add("display", "none");
pnlPg4.Visible = true
pnlPg4.Attributes.Add("display", "none");

then in your HTML add

<link href="print.css" type="text/css" rel="stylesheet" media="print">

print.css:
--------------
#pnlPg1 { display:; }
#pnlPg2 { display:; }
#pnlPg3 { display:; }
#pnlPg4 { display:; }
#pnlPg5 { display:; }
When you change the Visible Property in .NET it doesn't ever render the
control to the browser. If you have all the Visible Properties set to true
and use the css style display attribute = "" (blank-visible) or "none"
(invisible). Then every panel is rendered to the browser and you control
the visiblity on the client side using CSS

So the page uses the default CSS from you code on the screen layout, then
when you print using the it uses the printCSS and will make all panels
visible.

Let us know if this works.
Dec 19 '05 #4
what's "normal" anyway.

While *I* wouldn't do it this way, there's nothing wrong with your
approach

For your case
Set up another command button btnPrint

Private Sub btnPrint_Click(sender as Object, e as EventArgs) Handles
btnPrint.Click
pnlPg1.Visible = True
pnlPg2.Visible = True
pnlPg3.Visible = True
pnlPg4.Visible = True
pnlPg5.Visible = True
Page.RegisterStartupScript("PrintScript", "<SCRIPT
language='javascript'>window.print(); history.back();</SCRIPT>")
End Sub

Dec 19 '05 #5
I would probably have to agree. Setting up a print page would definately be
cleaner
Dec 19 '05 #6
JavaScript to the rescue!...again

I remember using a LOT of JavaScript with ASP.Classic

That gave me something to work with.

Thanks.
Ben Dewey wrote:
I would probably have to agree. Setting up a print page would definately be
cleaner


Dec 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Damien | last post by:
I have just built a simple stopwatch application, but when i f5 to get things goings i get this message, An unhandled exception of type 'System.ArithmeticException' occurred in...
4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
4
by: Jamey Shuemaker | last post by:
I've been looking for a way to do a duplex print job without a duplex printer. I reviewed some old posts about printing odd pages and found that most of them led to KB article 101075 or an export...
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
3
by: Tim | last post by:
Hi, I am creating my own method for printing. I am using PrintDocument and cycling through the data and creating new pages as neccessary. My question is, how can I know that total number of...
0
by: Ian | last post by:
Hi, I want to print a selection of pages from a PrintDocument. I have enabled the SomePages facility on the PrintDialog, and I am thus using the .FromPage and .ToPage properties of the...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
1
by: Stinky Pete | last post by:
Evening, I have a form that uses 5 pages (it's an electronic copy of the paper version) we are going to use for manufacturing non conformances and product deviations. In case your wondering,...
1
by: NewGuy | last post by:
Have a new job. I am creating dynamic(ajax) web pages that will update our databases. The DBs are on Linux. I have the AJAX built and on Linux. I am able to view my pages. Now I want to start...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.