I have a web application with asp.net 2.0 and I want to create a dropdown menu showing the printers installed on the client machine? How is that possible?
I tried the following code
foreach (string strPrinter in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
{
// add to list
}
but it shows only the local printers attached with the server, not the client m开发者_如何学JAVAachine.
You can't get it in ASP.NET because that's running on your server. You can't get it in Javascript either. It's just not available; see, for example, http://javascript.about.com/od/events/a/print_3.htm.
The only solution I can think of is to build an ActiveX control, and you then you could use the C# you have in the question, except running on the client. Of course, that limits you to IE.
if you want to show the installed printers on client machine, then you might have to use the javascript as the code you have written will be executed on server side.
精彩评论