-1

I am creating a web application and I want to print contents of my webpage. I have seen quite a lot of videos and support forums but I cant find what I'm looking for.

Basically PrintDialog is not available in my Visual Studio 2013 toolbox, is there any way of getting it? Or if possible not use PrintDialog because I cant find it. I have been using C#. I just want to know the simplest way to print.

P.S I am new at coding, any help and suggestions would be greatly appreciated. Thank you all

New Info ----

Sorry I should have been more clearer, basically I have different reports on my web page and i want users to be able to print the individual reports. They are mini reports in one page in different sections, I want to be able to print seperate sections

MissLadyBoo
  • 65
  • 2
  • 9
  • 1
    Hmm, the problem is getting the key to the server room so you pickup your printout. Clearly you ought to focus a bit on getting a printout from the *browser* you use to display the web page. Every browser already has that feature, no need to help. – Hans Passant Jun 29 '14 at 15:27

2 Answers2

1

Because the PrintDialog is for forms applications.

Each browser has its own printing implementation that you cannot influence.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
  • Oh I had a feeling that may be the case, any suggestions on what I should use? – MissLadyBoo Jun 29 '14 at 13:52
  • What do you want to do? Like I said, you can't change the browser's print dialog from the server side. – CodeCaster Jun 29 '14 at 13:52
  • I just want to print my web page by a click of a button. – MissLadyBoo Jun 29 '14 at 13:54
  • Using JavaScript, see for example [MVC4 C# How to implement a button to print the current information](http://stackoverflow.com/questions/19839537/mvc4-c-sharp-how-to-implement-a-button-to-print-the-current-information). – CodeCaster Jun 29 '14 at 13:55
1

To print the content of a webpage, you use the BROWSER's printdialog. In VERY OLD DAYS people added a "Click here to print" on websites, but actually you can just call:

window.print(); 

from Javascript OR press [CTRL+P] (or whatever key the browser you are using wants) or use the menues in the browser where there will be a print function available too.

The problem is that you dont instantiate the print from a HTML-server aka a webserver, and if you want to simulate that behaviour anyways, you will need a script, like Javascript in the page that will call the window.print() function.

This will still bring out the Printdialog and the user will still need actively to choose to actually print the thing, so you cant force it out on paper from server/site.

Think of the browser as a viewer/reader. Nothing else, and the server as the document storage.

BerggreenDK
  • 4,915
  • 9
  • 39
  • 61