Re: Printing from an ASP.NET page

Tech-Archive recommends: Fix windows errors by optimizing your registry



The problem with <body onload="window.print();window.close();"> is that the
browser still prompts the user about closing the window, so it doesn't save
the user any keystrokes. It is just as easy for them to close the window or
go to the previous page themselves. When selecting multiple reports, the
users will not like having to confirm closing the window for each report.
An alternative to "window.close" might be "history.go(-1)" but that does not
wait for the user to print before returning to the previous page.

Your latest suggestion is close, but I need a separate page for each
selected record, showing additional data (from the same table) that is not
shown in the GridView.

I have also tried using a ReportViewer control on the page, but I had
problems with that, too, including a persistent "parameter is missing a
value" error. Do you think the use of ReportViewer may have some potential?

The original server-side printing, using .NET printing methods works so
nicely in the Visual Studio test environment, it is disappointing that it
cannot be used on the real web server.

"Steven Cheng [MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:5AVjijV5IHA.1624@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Brett,

Thanks for your reply.

For the new question you mentioned. I would suggest you consider the
following approach:

1. One the original page (with Gridview), provide checkbox to let user
choose the rows to print

2. When the user click a print button, the page will postback, and you can
find all the selected rows(by looping the gridview to check checkbox
values) and redirect the user to a new page which will only display those
selected rows.

thus, on the new page the user can print what they exactly want. Just an
idea of generate a print version. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
From: "Brett" <brettlf@xxxxxxxxxxxxxxxx>
References: <OxehiRt4IHA.1428@xxxxxxxxxxxxxxxxxxxx>
<e#FIbdw4IHA.4688@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: Printing from an ASP.NET page
Date: Fri, 11 Jul 2008 09:11:49 -0400


Thank you, Steven and Nathan, for your quick response!

This is a web application and will print to a network printer. Ideally,
it
would print from the client-side, but server-side will be OK, because all
users are likely to use the same printer.

The application has been using the javascript "window.print" until now,
but
the users would like to be able to select multiple rows from the GridView
and print them all with one click. Is this possible?

Thanks!
Brett

"Steven Cheng [MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:e%23FIbdw4IHA.4688@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Brett,

As for the report printing, do you want it to print at the client-side
machine or server-side machine. As Nathan has mentioned, ASP.NET web
application is totally running separate from client-side browser
environment. for printing, you have the following different choice:

1. Let page opened in client-side webbrowser and user click browser's
"print" menu to print. Or you can use javascript "window.print()" to
print
the current page. However, our server-side web application doesn't have
much control on the client-side printing setting or printers

2. You only want to print at server-side, then, you can use printing
code
in your asp.net server-side code , such code will only use printers at
ASP.NET web server, and the client user will never see what happed for
the
printers at server-side.

The reason why you'll see some different behavior(the client user can
also
see server-side printing code work) when using visual studo test server
is
as below:

** visual studio test server is a winform application which runs on
local
machine(under the current logon user).

** so if you use any desktop application code(such as winform code) in
asp.net pages which hosted in visual studio test server, it will also be
visible

** however, if you deploy the ASP.NET application to IIS, that's totally
different. IIS worker process runs under a non-visible user session and
under an different non-interactive user account.

If you have anything unclear on this, please feel free to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead





.


Quantcast