Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing out an ASP.NET Page

Status
Not open for further replies.
Feb 8, 2002
43
US
I have a simple web page that contains a user cotrol across the top for navigation and a user control down the left side for navigation (standard layout).

How do I print out the contents of the page to automatically fit the portait landscape so that the entire page fits horizontally without being cut off. I would like to set this from the IE menu bar but that's not necessary (I could write a function to do this but I would like to know how).

If that is not possible how do I write a function that prints out only the main section of the page while leaving out the top and side user controls?
 
If your looking for a way to programtically tell the browser to print landscape then I think your out of luck - sorry. However to only print the main section is easy with css.

When you specify a stylesheet or style bloxk there is an attribute of the <link> or <style> tag depending on which method you use called 'media' set this to print and then these styles will override any screen styles when the browsers send the page for printing. Alternatively you could place a media block in a screen css to do the same thing. Here some examples...

<link href=&quot;&quot; media=&quot;print&quot;>

<style type=&quot;text/css&quot; media=&quot;print&quot;>

or in a screen stylesheet a bloxk like

@media print{
/*print styles in here*/
}

To create the effect your after then give the top and side controls an id and then in your pront styles set the display property to none like this..

#top{display:none;}
#side{display:none;}

Now only the main sectionw ill print. You can test this using the print preview function in the browser..

hope this helps

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top