Print

  • Thread starter Thread starter Catalin Porancea
  • Start date Start date
C

Catalin Porancea

Hello,

How do I print a web form as soon as it is displayed, without any user
intervention?

Thank you,
Catalin
 
you dont unless you want to print it serverside, to a serverside printer.
You can prompt the user for printing but you can't force it, unless possibly
you can get them to install a component or such.
 
You can bring the PrintDialog up with some client side script, but you can't
force them to print it.

window.print()

HTH,

bill
 
Forced printing would breach the security of the browser unless being done
by a signed applet or activeX control of some sort. It would be a spammers
dream.

The best you can do is invoke the print dialogue via javascript and hope
they print.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
 
Thanks guys. Can anybody show me the script to show the print dialog?

Thank you.
 
Try this

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP


<html>
<head>
<script language="VB" runat="server">


'Sub Page_PreRender()

Sub Page_Load( sender as Object,e as EventArgs)

Dim scriptString as String = "<script language=JavaScript> function
DoClick() {"
ScriptString += "var truthBeTold = window.print;"
ScriptString += "if (truthBeTold != null)"
ScriptString += "window.print();"
ScriptString += "else window.alert('Unfortunately, your browser does
not support this shortcut. Please select File and then Print from your
browsers menu.');}<"
scriptString += "/"
scriptString += "script>"

If(Not IsClientScriptBlockRegistered("clientScript"))
RegisterClientScriptBlock("clientScript", scriptString)
End If
End Sub
</script>
</head>
<body topmargin="20" leftmargin="10">
<form id="myForm" runat="server">
<input type="button" value="ClickMe" onclick="DoClick()">
</form>
</body>
</html>
 
Thanks John.

But in this way, the user has to click on the "Click Me" button to display
the print dialog. I want the print dialog to pop up without the user
clicking on anything (at load).
 
just call the function in the body on-load event client side

<body onload=DoClick() >

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
 
Thanks John

John Timney (Microsoft MVP) said:
just call the function in the body on-load event client side

<body onload=DoClick() >

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
 
Back
Top