Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

Print part of a page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe Kovac - 17 Oct 2007 09:28 GMT
Hi!

I would like to create a page, where the user can print the lower part
of the page by pressing a button.
It might look like this:

-----------------------------------------------
o Setting 1   o Setting 2    Input: <TextBox>

PrintButton

+----------------+
| printable part |
+----------------+
-----------------------------------------------

The printable part shall be influenced by the settings above it. After
the user selects the settings he needs he can push the print button and
print the printable part only.

Thanks for your help

Joe
Eliyahu Goldin - 17 Oct 2007 10:06 GMT
Important thing to understand is that browsers can print only the whole
page. You can achieve printing part of the page by hiding controls you don't
want to print or by setting their css style.

You can do it either on client or server side.

On client side you can handle onbeforeprint and onafterprint events to
hide/show parts of the printable area. You will need to write some
javascript code to check the Setting controls and to locate and hide
controls in the printable part.

You can also create a special stylesheet for printing like this:
<link rel="stylesheet" type="text/css" media="print" href="print.css" />

and manipulate with control css classes either or server or client side.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Hi!
>
[quoted text clipped - 19 lines]
>
> Joe
Joe Kovac - 17 Oct 2007 12:45 GMT
> Important thing to understand is that browsers can print only the whole
> page. You can achieve printing part of the page by hiding controls you don't
[quoted text clipped - 6 lines]
> javascript code to check the Setting controls and to locate and hide
> controls in the printable part.

I didn't find any onbeforeprint and onafterprint events. Where can I
find some information on that?

I tried following:
function myPrint()
{
  document.getElementById('<%= div1.ClientID %>').style.display = 'none';
  window.print();
  document.getElementById('<%= div1.ClientID %>').style.display = '';
}

Making the elements visible again happens too early. So the hidden part
gets displayed on the printed sheet. Any ideas how to solve that?

> You can also create a special stylesheet for printing like this:
> <link rel="stylesheet" type="text/css" media="print" href="print.css" />
>
> and manipulate with control css classes either or server or client side.
Eliyahu Goldin - 17 Oct 2007 13:09 GMT
Putting the code for making visible in onafterprint will solve your problem.

http://msdn2.microsoft.com/en-us/library/ms536788.aspx
http://msdn2.microsoft.com/en-us/library/ms536906.aspx

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

>> Important thing to understand is that browsers can print only the whole
>> page. You can achieve printing part of the page by hiding controls you
[quoted text clipped - 25 lines]
>>
>> and manipulate with control css classes either or server or client side.
Joe Kovac - 17 Oct 2007 14:08 GMT
Thanks. But how about FF?

> Putting the code for making visible in onafterprint will solve your problem.
>
> http://msdn2.microsoft.com/en-us/library/ms536788.aspx
> http://msdn2.microsoft.com/en-us/library/ms536906.aspx
Eliyahu Goldin - 17 Oct 2007 14:20 GMT
Right, they won't wok in FF. Research the css option.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Thanks. But how about FF?
>
[quoted text clipped - 3 lines]
>> http://msdn2.microsoft.com/en-us/library/ms536788.aspx
>> http://msdn2.microsoft.com/en-us/library/ms536906.aspx
Joe Kovac - 19 Oct 2007 13:54 GMT
> Right, they won't wok in FF. Research the css option.

Thanks. The css option works great. I just hide what shall not be
printed using a "noprint" class.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.