开发者

Printing a separate report webpage without displaying in ASP.NET

开发者 https://www.devze.com 2023-04-11 01:18 出处:网络
This is somewhat related to my previous printing question re: remote printing, which I resolved with help here at work.This new situation likely has a simple answer as well, but I have yet to discover

This is somewhat related to my previous printing question re: remote printing, which I resolved with help here at work. This new situation likely has a simple answer as well, but I have yet to discover it.

To simplify, I have two webpages written in ASP.NET with C# codebehind, which we can call page1.aspx and page2.aspx.

The first page, page1.aspx, is a simple search tool that opens a database and returns a list of reports matching the search criteria into a gridview. The second page, page2.aspx, displays a report in the web browser, given the report ID as a query variable (which I have working). This page is also pre-formatted to be printer friendly.

On page1.aspx, in my gridview, I have two buttons for each row labeled "View" and "Print". The "View" button will retrieve the appropriate order number for the corresponding row, and page2.aspx will load the report 开发者_JAVA百科based on the order number (again passed as a query variable).

For the "Print" button, however, I would like to print. That is, when the user clicks the button, instead of the page loading onto the screen, I would like for the Print dialog to pop up and allow the user to print the report directly to the printer (since they are able to view the report using the separate button if they should so desire).


I would load page2 into an iframe, probably separately and have the page call a JavaScript print when loaded, or call focus on the iframe and then print on the same object.

You could load the page with a new call, or just load it when page1 loads in the background.

You would, of course, make the iframe hidden from view.

0

精彩评论

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