By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,210 Members | 1,858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,210 IT Pros & Developers. It's quick & easy.

PrintToPrinter command does not work on the web server?

P: n/a
I am having problems with the PrintToPrinter command. It works fine in the
development environment but when I try using this on the web server it does
not work.

I am having problems debuging this because I get an error when my code hits
the msgbox command as well "Showing a modal dialog box or form when the
application is not running in UserInteractive mode is not a valid
opperation". I have a feeling this is because the code is in the page_load
sub.

Does anyone know why the PrintToPrinter command does not work?
This is my code.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim Stage As Integer = 0
Dim myPrintOptions As PrintOptions = NonJSDeliveryNote.PrintOptions

myPrintOptions.PrinterName = Session("Printer").ToString()
If Not IsPostBack Then
Try
NonJSDeliveryNote.PrintToPrinter(1, False, 0, 0)
Stage = 1
Response.Redirect("ShipSummary.aspx")
Exit Try
Catch ex As Exception
If Stage = 0 Then
MsgBox(ex.Message)
End If
End Try
End If
End Sub
--
Derek
Jun 14 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
This turned out to be an ODBC problem. The DNS name on the server was
different to the name I used when developing the reports so it couldn't
connect to the server.
--
Derek
"Derek" wrote:
I am having problems with the PrintToPrinter command. It works fine in the
development environment but when I try using this on the web server it does
not work.

I am having problems debuging this because I get an error when my code hits
the msgbox command as well "Showing a modal dialog box or form when the
application is not running in UserInteractive mode is not a valid
opperation". I have a feeling this is because the code is in the page_load
sub.

Does anyone know why the PrintToPrinter command does not work?
This is my code.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim Stage As Integer = 0
Dim myPrintOptions As PrintOptions = NonJSDeliveryNote.PrintOptions

myPrintOptions.PrinterName = Session("Printer").ToString()
If Not IsPostBack Then
Try
NonJSDeliveryNote.PrintToPrinter(1, False, 0, 0)
Stage = 1
Response.Redirect("ShipSummary.aspx")
Exit Try
Catch ex As Exception
If Stage = 0 Then
MsgBox(ex.Message)
End If
End Try
End If
End Sub
--
Derek

Jun 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.