Click to See Complete Forum and Search --> : printing an asp.net page


glenda
April 22nd, 2003, 06:54 AM
does anyone know how to get the print dialogue box to popup so that a web client can print the .aspx page?

pleeeaaasee...

DSJ
April 22nd, 2003, 11:19 AM
You have to run some script on the client. For example to bring up the print dialog from an HTML Button control, add the "OnClick" event like:

<INPUT id="Btn_Print" style="Z-INDEX: 105; LEFT: 379px; WIDTH: 147px; POSITION: absolute; TOP: 308px; HEIGHT: 30px" type="button" value="Print" onclick="window.print()">

V. Lorenzo
April 28th, 2003, 06:33 AM
Hi:

Using JScript you may gain access to some of the objects exposed by the user agent (explorer). The one that could be useful for you, in this case, is the 'window' object.

The simpler code sample could be the following, assuming that you have added an INPUT tag of type Button, so the code executes on the client, not on the server, with the onclick event handler set as :

onclick = "javascript:window.Print()".

This sample/simple code pops up the printer dialog so you can print your page.

Bye