Last post Jan 22, 2016 07:43 PM by Madog
Jan 04, 2016 11:24 PM|CCGPlayer|LINK
Jan 05, 2016 12:39 AM|oned_gk|LINK
protected void Button1_Click(object sender, EventArgs e)
ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "window.print()", true);
Jan 05, 2016 12:48 AM|ninianne98|LINK
just put this in your html
Jan 05, 2016 05:43 PM|CCGPlayer|LINK
button is selected, instead of printing the current webpage, I could have it instead go to my print method. Would window.print still apply?
Jan 05, 2016 07:53 PM|ninianne98|LINK
window.print should just launch the print dialog, not immediately start printing. you should have the opportunity to select printer and quality etc. You'll likely be limited to printing either a test page or the current page, however, as there's not really
Jan 05, 2016 08:55 PM|CCGPlayer|LINK
If Window.print() can't be intercepted, is there possibly an alternative out there?
Jan 06, 2016 06:15 AM|XIII|LINK
I'm looking for the ability for the printer dialog to appear on a button click, but when the "Print" button is selected, instead of printing the current webpage, I could have it instead go to my print method. Would window.print still apply?
Where do you want to print the page? If you simply send a request to the server by a button click you can print with .NET to a connected printer of the server. If however you want to print on a printer which is not known by the server but is for examply
a printer connected to the pc of the enduser then it's a no go for security reasons. It's still up to the user to get the print dialog and let her/him decide if she/he wants to print the document or not.
Jan 21, 2016 09:44 PM|CCGPlayer|LINK
I'm NOT trying to print the current page. I have a list of items that is displayed on a web page with a checkbox next to them. When a checkbox is checked, it signifies that the related details are to be printed. When the "Print Details" button is checked,
it loops through the list and prints out the details. The print routine itself works fine, but I'm not able to display a printer dialog box before hand so it just prints to the current default printer.
Jan 21, 2016 10:37 PM|PatriceSc|LINK
It is still unclear. My understanding is that you print from code behind and that the problem is that it goes to your default printer but that you would like instead to let the user to select the printer.
Unfortunately it is not how it works. Keep in mind that your code behind runs server side so on a real web server you would print to the default SERVER side printer for the account that runs your code (and that usually doesn't even have a printer configured).
So if I understood your code behind pirnting just won't work anyway.
As I understand things instead you could do something such:
- let the user to select what he wanrts to print and use a "print" button
- prepare the HTML markup you want to print. You could show it in a new window or maybe even in the current window but being hidden. You can use a style sheet that is used for pirnting and so it should allow to print this hidden markup rather than what is shown
on the screen
- and so you can call window.print() and let the user to select the printer and print what you have prepared behind the scene
Jan 22, 2016 04:17 AM|markfitzme|LINK
You have no control over the client printer. If you are printing from code behind keep in mind any printing done there will be to the server's printer, which in all likelihood it doesn't have any.
Jan 22, 2016 07:43 PM|Madog|LINK