开发者

how can Printing a Web Page in Asp.Net without Header and Footer - ASP.NET

开发者 https://www.devze.com 2023-01-06 10:56 出处:网络
how can Printinga Web Page in A开发者_Python百科sp.Net without Header and Footer You can add a css type for printing, and change the css to hide what you don\'t want printed.

how can Printing a Web Page in A开发者_Python百科sp.Net without Header and Footer


You can add a css type for printing, and change the css to hide what you don't want printed.

For example, you can put this code in your main css file:

@media print {
    .noPrint { display:none; }
}

When printing, it will not display any of the tags using the class noPrint.


You can either have a "print version" button, which allows the server to serve up a version of the page without certain server side elements (panels, etc.) visible, or you can implement a print CSS file, which will seamlessly format your content when people print.

CSS is the better option in my opinion. Here is a great resource on the subject:

http://www.alistapart.com/articles/goingtoprint/


The header and footer text can be determined by the browser. Many users may not be aware of this, so they get the default print settings, which often include the website URL and the date.

Since this is a browser setting, controlled by the user, you may not be able to override it.

To see the browser print settings, try menu File - Page Setup. That works in IE and Firefox.


I did a similar implementation by defining a "print" version of the master page.

When print button was clicked, I assigned the "print" version of the master page to the current page.

Very easy to do !

0

精彩评论

暂无评论...
验证码 换一张
取 消