views:

835

answers:

3

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 machine.

A: 

maybe this will help:

http://stackoverflow.com/questions/296182/how-to-get-printer-info-in-c-net

GxG
he's asking about the client's printers, not the server's
Isaac Cambron
in that case you need to run a clientside script. i think that jquery already has a builtin function to do this... but i'm not sure
GxG
A: 

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.

Tumbleweed
A: 

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.

Isaac Cambron