Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PrintDialog class and ASP.NET ??

Status
Not open for further replies.

hanglam

Programmer
Joined
Dec 11, 2002
Messages
143
Location
US
Hi, I'm designing a .aspx web page that allows a user to print a document when they click a button. I want to be able to let the user be able to pick a printer by displaying a PrintDialog screen. In VB.NEt, I will use the PrintDialog class to display the dialog but I can't seem to do it in ASP.NET.

My question is : how do I display a PrintDialog in ASP.NET ?
or a better question is how do I do server-side printing in ASP.NET?

Thanks,
Hang
 
I can tell you what you can't do. You can initiate a Print Dialog box using VB.Net on the clients computer. You can, however, use a little bit of javascript like this:
Code:
  <SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function varitext(text){
text=document
print(text)
}
//  End -->
  </SCRIPT>
 </HEAD>
<body onload=&quot;varitext();&quot;>

in your aspx page. This simply gives them a browser print dialog box, which will print whatever they see in their browser window.

Now, as far as your code triggering a page to be printed on the server side? I wouldn't mind learning about that myself. I would assume you would have to create a class which would be derived from PrintDocument that sat on the server and would be called from your WebForm code.
 
Adding this line of code in your code-behind file will cause the Print Dialog to appear in your client's browser.

RegisterStartupScript(&quot;printscript&quot;, &quot;<script>window.print();</script>&quot;)

Neil Konitzer
Freisoft
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top