Asp. NET page Print __.net

Source: Internet
Author: User

Asp. NET page printing (20041117)

A system will certainly have a report or query, then it means to use the print, and ASP.net page print how to achieve it? Through my practice, summed up as follows:
1. Crystal Report
Advantages: Powerful, flexible to define the report.
Disadvantages: Not easy to deploy (transplant inconvenient, need to refer to components and input licenet, etc.), to achieve cumbersome
Implementation: First establish the report (. rpt file) and place a Crystalreportviewer control on the page you want to print, assigning the report source to the page control before printing.
2. Print the page
Advantages: Simple to implement and easy to use.
Disadvantage: page settings are not flexible.
Implementation: Passing parameters to the printed page (preset report style) when printing and display the data you want to print, and then press "print" directly in the toolbar. But by default, when printed with a header and footer, you want it to be taken off when printing (of course you can manually set it, if the customer wishes), There are two ways to implement a program, but it must be a client code implementation, because if the service-side code is implemented, the settings for the server will be modified as follows:
A. Modifying the Registry
<script language= "JavaScript" >
var Hkey_root,hkey_path,hkey_key;
Hkey_root= "HKEY_CURRENT_USER";
Hkey_path= "Software//microsoft//internet explorer//pagesetup//";
Set page header to print with empty headers and footers
function Pagesetup_null ()
{
Try
{
var wsh=new activexobject ("Wscript.Shell");
hkey_key= "Header";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "");
hkey_key= "Footer";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "");
}
catch (e) {}
}
Set the page header footer to be printed by default
function Pagesetup_default ()
{
Try
{
var wsh=new activexobject ("Wscript.Shell");
hkey_key= "Header";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "&w&b page number, &p/&p");
hkey_key= "Footer";
Wsh.regwrite (Hkey_root+hkey_path+hkey_key, "&u&b&d");
}
catch (e) {}
}
</script>
After you set up the above two functions, click on the print to call the corresponding function.

B. Using ActiveX controls
There is a Scriptx.cab control on the Internet, the function of which can call the "Page Setup" dialog box to set up, detailed instructions can be obtained from the Internet, did not do the test.

However, both of the above methods will need to set the IE security level to the minimum.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.