473,692 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing from an ASP.NET page

I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing classes, for each of the
checked rows in the GridView. This works fine in the Visual Studio 2005
development environment on localhost. But, when I move the page to the web
server, I get the error "Settings to access printer
'\\ServerName\P rinterName' are not valid." (See below.) I get the same
error if I try this while logged into the server, but I can successfully
print a test page from the server.

This printer is installed on the server and is the default printer. The
server is running Windows Server 2003 R2 Service Pack 2, IIS 6 and ASP.NET
2.0.50727.0. Is there any way that I can have this report print when the
page is hosted on the web server? Thank you!

Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Drawing. Printing.Invali dPrinterExcepti on: Settings
to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not valid.

Source Error:

Line 194:Line 195: PrintDoc.Print( )Line 196:
PrintDoc.Dispos e()Line 197: End Sub

Source File: C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb
Line: 195

Stack Trace:

[InvalidPrinterE xception: Settings to access printer '\\COLUMBIA\IT Hallway
FS-3820N KX' are not valid.]
System.Drawing. Printing.Printe rSettings.GetHd evmodeInternal( ) +123451
System.Drawing. Printing.Printe rSettings.GetHd evmode(PageSett ings
pageSettings) +48
System.Drawing. Printing.PrintC ontroller.OnSta rtPrint(PrintDo cument document,
PrintEventArgs e) +81
System.Windows. Forms.PrintCont rollerWithStatu sDialog.OnStart Print(PrintDocu ment
document, PrintEventArgs e) +33
System.Drawing. Printing.PrintC ontroller.Print (PrintDocument document) +201
System.Drawing. Printing.PrintD ocument.Print() +111
_Default.PrintW orkOrder() in
C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb:195
_Default.btnPri nt_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb:180
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +105
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+107
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl,
String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint,
Boolean includeStagesAf terAsyncPoint) +1746

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

Version Information: Microsoft .NET Framework Version:2.0.507 27.1433;
ASP.NET Version:2.0.507 27.1433
Jul 10 '08 #1
18 11294
Are you creating a web or desktop application? I notice that the Stack Trace
contains the following:

System.Windows. Forms.PrintCont rollerWithStatu sDialog.OnStart Print(PrintDocu ment
document, PrintEventArgs e) +33

The System.Windows. Forms namespace is never used in an ASP.NET application.
If you want to print an ASP.NET page, you will need to use the JavaScript
window.print() method. If you want to have a printable version generated
when the user clicks the button or link to print, I would suggest the
following:

1. Create another page that generates the appropriate report (probably using
a querystring)
2. In the link to this page, be sure to include target="_blank" so that the
page opens in a new window
3. Use the following for the body tag of the new page, which will print the
page and then close it:

<body onload="window. print();window. close();">

This technique will allow the user to bring up their browser's print dialog,
close the window, and return to the previous page with the click of a single
button or link. If you are trying to make a desktop application, well, then,
you are posting to the wrong newsgroup. Good Luck!
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Brett" <br*****@newsgr oup.nospamwrote in message
news:Ox******** ******@TK2MSFTN GP06.phx.gbl...
>I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing classes, for each of the
checked rows in the GridView. This works fine in the Visual Studio 2005
development environment on localhost. But, when I move the page to the web
server, I get the error "Settings to access printer
'\\ServerName\ PrinterName' are not valid." (See below.) I get the same
error if I try this while logged into the server, but I can successfully
print a test page from the server.

This printer is installed on the server and is the default printer. The
server is running Windows Server 2003 R2 Service Pack 2, IIS 6 and ASP.NET
2.0.50727.0. Is there any way that I can have this report print when the
page is hosted on the web server? Thank you!

Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Drawing. Printing.Invali dPrinterExcepti on:
Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.

Source Error:

Line 194:Line 195: PrintDoc.Print( )Line 196: PrintDoc.Dispos e()Line
197: End Sub

Source File: C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb
Line: 195

Stack Trace:

[InvalidPrinterE xception: Settings to access printer '\\COLUMBIA\IT
Hallway FS-3820N KX' are not valid.]
System.Drawing. Printing.Printe rSettings.GetHd evmodeInternal( ) +123451
System.Drawing. Printing.Printe rSettings.GetHd evmode(PageSett ings
pageSettings) +48
System.Drawing. Printing.PrintC ontroller.OnSta rtPrint(PrintDo cument
document, PrintEventArgs e) +81
System.Windows. Forms.PrintCont rollerWithStatu sDialog.OnStart Print(PrintDocu ment
document, PrintEventArgs e) +33
System.Drawing. Printing.PrintC ontroller.Print (PrintDocument document) +201
System.Drawing. Printing.PrintD ocument.Print() +111
_Default.PrintW orkOrder() in
C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb:195
_Default.btnPri nt_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb:180
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +105
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+107
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler sourceControl,
String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +33
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint) +1746

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

Version Information: Microsoft .NET Framework Version:2.0.507 27.1433;
ASP.NET Version:2.0.507 27.1433


Jul 11 '08 #2
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
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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Brett" <br*****@newsgr oup.nospam>
Subject: Printing from an ASP.NET page
Date: Thu, 10 Jul 2008 17:29:53 -0400
>
I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing classes, for each of
the
>checked rows in the GridView. This works fine in the Visual Studio 2005
development environment on localhost. But, when I move the page to the
web
>server, I get the error "Settings to access printer
'\\ServerName\ PrinterName' are not valid." (See below.) I get the same
error if I try this while logged into the server, but I can successfully
print a test page from the server.

This printer is installed on the server and is the default printer. The
server is running Windows Server 2003 R2 Service Pack 2, IIS 6 and ASP.NET
2.0.50727.0. Is there any way that I can have this report print when the
page is hosted on the web server? Thank you!

Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Drawing. Printing.Invali dPrinterExcepti on:
Settings
>to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not valid.

Source Error:

Line 194:Line 195: PrintDoc.Print( )Line 196:
PrintDoc.Dispo se()Line 197: End Sub

Source File: C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb
Line: 195
Jul 11 '08 #3
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.pri nt" 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]" <st*****@online .microsoft.comw rote in message
news:e%******** ********@TK2MSF TNGHUB02.phx.gb l...
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
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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>From: "Brett" <br*****@newsgr oup.nospam>
Subject: Printing from an ASP.NET page
Date: Thu, 10 Jul 2008 17:29:53 -0400
>>
I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing classes, for each of
the
>>checked rows in the GridView. This works fine in the Visual Studio 2005
development environment on localhost. But, when I move the page to the
web
>>server, I get the error "Settings to access printer
'\\ServerName \PrinterName' are not valid." (See below.) I get the same
error if I try this while logged into the server, but I can successfully
print a test page from the server.

This printer is installed on the server and is the default printer. The
server is running Windows Server 2003 R2 Service Pack 2, IIS 6 and ASP.NET
2.0.50727.0 . Is there any way that I can have this report print when the
page is hosted on the web server? Thank you!

Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.
Description : An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Drawing. Printing.Invali dPrinterExcepti on:
Settings
>>to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not valid.

Source Error:

Line 194:Line 195: PrintDoc.Print( )Line 196:
PrintDoc.Disp ose()Line 197: End Sub

Source File: C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb
Line: 195

Jul 11 '08 #4
"Brett" <br*****@newsgr oup.nospamwrote in message
news:OC******** *******@TK2MSFT NGP05.phx.gbl.. .
The application has been using the javascript "window.pri nt" 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?
I always use a PDF solution for printing. This gives total flexibility e.g.
once the PDF document has been created, it's just as easy to send it to a
network printer which the webserver can see as it is to stream it to the
client browser so that the user can do what they like with it. Also, a PDF
document is (pretty much) guaranteed to display and print the same
regardless of browser, OS, printer etc.

I use this exclusively: http://www.siberix.com/. It's very simple to use,
especially if you're familiar with XML, and comes as a native .NET assembly
i.e. no printer driver to install.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 11 '08 #5
If you want it to print specific rows, do something like add a checkbox to
each row and then generate a page using some variation of my original
suggestion.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

"Brett" <br*****@newsgr oup.nospamwrote in message
news:OC******** *******@TK2MSFT NGP05.phx.gbl.. .
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.pri nt" 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]" <st*****@online .microsoft.comw rote in message
news:e%******** ********@TK2MSF TNGHUB02.phx.gb l...
>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(unde r 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
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:
ms****@microsof t.com.

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

============== =============== =============== ======
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
>>>From: "Brett" <br*****@newsgr oup.nospam>
Subject: Printing from an ASP.NET page
Date: Thu, 10 Jul 2008 17:29:53 -0400
>>>
I have an ASP.NET page that displays work orders in a GridView. In that
GridView is a checkbox column. When the user clicks a "Print" button, I
create a report, using the .NET Framework printing classes, for each of
the
>>>checked rows in the GridView. This works fine in the Visual Studio 2005
developmen t environment on localhost. But, when I move the page to the
web
>>>server, I get the error "Settings to access printer
'\\ServerNam e\PrinterName' are not valid." (See below.) I get the same
error if I try this while logged into the server, but I can successfully
print a test page from the server.

This printer is installed on the server and is the default printer. The
server is running Windows Server 2003 R2 Service Pack 2, IIS 6 and
ASP.NET
2.0.50727. 0. Is there any way that I can have this report print when the
page is hosted on the web server? Thank you!

Settings to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not
valid.
Descriptio n: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Drawing. Printing.Invali dPrinterExcepti on:
Settings
>>>to access printer '\\COLUMBIA\IT Hallway FS-3820N KX' are not valid.

Source Error:

Line 194:Line 195: PrintDoc.Print( )Line 196:
PrintDoc.Dis pose()Line 197: End Sub

Source File: C:\Inetpub\wwwr oot\Maintenance Manager\WorkOrd ers.aspx.vb
Line: 195


Jul 11 '08 #6
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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Brett" <br*****@newsgr oup.nospam>
References: <Ox************ **@TK2MSFTNGP06 .phx.gbl>
<e#************ **@TK2MSFTNGHUB 02.phx.gbl>
>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.pri nt" 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]" <st*****@online .microsoft.comw rote in message
news:e%******* *********@TK2MS FTNGHUB02.phx.g bl...
>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(unde r 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

Jul 14 '08 #7
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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Brett" <br*****@newsgr oup.nospam>
References: <Ox************ **@TK2MSFTNGP06 .phx.gbl>
<e#************ **@TK2MSFTNGHUB 02.phx.gbl>
>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.pri nt" 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]" <st*****@online .microsoft.comw rote in message
news:e%******* *********@TK2MS FTNGHUB02.phx.g bl...
>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(unde r 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

Jul 14 '08 #8
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.clo se" 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]" <st*****@online .microsoft.comw rote in message
news:5A******** ******@TK2MSFTN GHUB02.phx.gbl. ..
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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>From: "Brett" <br*****@newsgr oup.nospam>
References: <Ox************ **@TK2MSFTNGP06 .phx.gbl>
<e#************ **@TK2MSFTNGHUB 02.phx.gbl>
>>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.pri nt" 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]" <st*****@online .microsoft.comw rote in message
news:e%****** **********@TK2M SFTNGHUB02.phx. gbl...
>>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(und er 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


Jul 14 '08 #9
Hi Brett,

Thanks for your further reply.

As for ReportViewer, I think the printing functionality is also quite
limited since you cannot control the printing setting in code(but let the
user choose when click print button).

For server-side printing, it is not completely unavailable, but no
recommended. You can try the following:

1. first check your server-side printing code(which use some winform
printing code) to ensure that the one will not require any interactive
operations such as prompt dialog box that need a user to respond. All the
code should be able to finish programmtically without UI.

2. You can try changing your ASP.NET application's worker process
account(for IIS6 it is the application pool identity). Switch it to an
interactive user account such a domain user account or local logon user so
that it can access the certain printers. Or you can consider using
impersonate at runtime to let your application running under a certain user
account.

Here are some information about IIS worker process identity and impersonate
in ASP.NET

#How To: Use Impersonation and Delegation in ASP.NET 2.0
http://msdn.microsoft.com/en-us/library/ms998351.aspx

#How to implement impersonation in an ASP.NET application
http://support.microsoft.com/kb/306158

#IIS Worker processes & windowstation/desktops
http://blogs.msdn.com/nicd/archive/2...desktop-settin
gs.aspx

BTW, if the printing task is a frequently used functionality on your
webserver, I suggest you also consider the following approach:

* create a separate winform application running on the server which will
receive printer request(with necessary data) and do the printing task to
certain printers on the server

* Your ASP.NET application will always send printing task request to that
winform application. the communication channel maybe any existing remoting
approach such as : remoting, webservice, WCF, MSMQ....

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:
ms****@microsof t.com.

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

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: "Brett" <br*****@newsgr oup.nospam>
References: <Ox************ **@TK2MSFTNGP06 .phx.gbl>
<e#************ **@TK2MSFTNGHUB 02.phx.gbl>
<OC************ *@TK2MSFTNGP05. phx.gbl>
<5A************ **@TK2MSFTNGHUB 02.phx.gbl>
>Subject: Re: Printing from an ASP.NET page
Date: Mon, 14 Jul 2008 16:49:43 -0400
>
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.clo se" 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]" <st*****@online .microsoft.comw rote in message
news:5A******* *******@TK2MSFT NGHUB02.phx.gbl ...
>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

Jul 15 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1569
by: Thomas Miskiewicz | last post by:
Hi! I'm using the page-break-before:auto thing with my IE 6.0.2600.0000 and it works fine. However when I go into printing preview and printing it's showing adding a empty row by the end of every page. Do you guys know how to get rid of that? thanks Tom
0
1429
by: geoffhanna | last post by:
I am not referring to the standard PrintDialog. This dialog pops up every time my printdocument.printpage event fires. He only has one button - "Cancel" and contains no other controls I am printing multiple documents in a batch and this guy just flashes all over the place. It looks really bad but even worse, is significantly slowing performance I cannot find a setting anywhere that will suppress this dialog. Anyone?
3
2988
by: millind | last post by:
I have a small issue. I have a html page which i need to print it legal size. My default printer setting is letter. How can i set a script which will print just this page in legal without change the printer settings
0
1123
by: vinki | last post by:
Hi Everyone, I have this xslt file. I want to print the page directly to the printer after every MOP template is matched. So for example the ouput is coming to the HTML page like this Phone: (909) 549-3419
1
1600
by: Marc | last post by:
Hi, I am setting up a orint function that prints the screen area. It is all working except my screen area spans two print pages hwne viewed using a print preview dialogue . I am trying to fnd a way to make the print area fit onto a standard A4 paper print area. Anyone any idea how I can control this and 'shrink' my current print document?
2
1538
by: jed | last post by:
Hi guys. I have a html page which I want to print. The page simply contains A page/title header, say "Web Printing 101" and some body text. Now I send to a printer and everythings fine. My problem is when the body text span to more than a page (e.g page2,page3). I still want to print (retain) the page title on these succeding pages, just like in the case of Letterheads. Is there a way, using PHP, to print those page headers to succeeding...
2
2908
by: Simon | last post by:
Dear reader, In case a report is a sub report the Report Header of the sub report is printed in the report but the Page Header of the sub report will not be printed. This is the same for Page Footer of the sub report. Is there a possibility to force printing Page Header and Page Footer of a sub report.
5
14219
by: gotonagle | last post by:
hi all i have one page that generates a report (basically a table ) in ASP.i have a button that prints that page using window.print(). now i want to print that page in landscape mode (by default its printing in potrait mode). i dont want to ask user to change orientation from print window. pls let me know if we can have any such javascript or server script that either change the printer setting or make the page or div to be printed as...
0
1327
by: pratimapaudel | last post by:
Hi I have created reports in SQL SERVER 2005 Reporting service. But my report is not printing all the columns in one page. It is breaking the columns in two pages. I have tried to set up the width and height property but i could not fix this problem. Can anyone help me? Thanks
2
11243
by: winzone | last post by:
Hi All, Now i use the following code to print the data in C# 2005 application. But i face the problem is total page number at the begining of first page. They want to get page number like : Page : 1 of 15. Is there any suggesting how to get total page number. Public int y = 0; Public int LineCount = 0; int yPosition = 50; e.Graphics.DrawString("Summary of Image Data", drawHeaderFont, drawBrush, 50, yPosition,...
0
8538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9083
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8961
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8801
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6459
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5819
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4324
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1957
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.