print method in Javascript

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a asp.net web form with one datagrid which is used to display some information in tabular format. However, in the page, there are 2 buttons which are "Save" and "Print", when i save the page, i can make the page saved without the 2 buttons in the saved page. However, when i try to print the page by clicking the button, the 2 buttons are shown in the printed page. The result which i want is the page printed without the 2 buttons, how can i achieve this by using javascript. Currently i am using "print()" method in Javascript. Please advice, thank you so much.
 
I have created a asp.net web form with one datagrid which is used to display some information in tabular format. However, in the page, there are 2 buttons which are "Save" and "Print", when i save the page, i can make the page saved without the 2 buttons in the saved page. However, when i try to print the page by clicking the button, the 2 buttons are shown in the printed page. The result which i want is the page printed without the 2 buttons, how can i achieve this by using javascript. Currently i am using "print()" method in Javascript. Please advice, thank you so much.

Simplest method is to use a Javascript function to do the printing.
Instead of having the button call the print() method, have it call a
method you write... lets say printme().

<button id='printbutton' onclick="printme();".... >

Now write printme...

function printme() {
document.all ['printbutton'].visible = false;
document.print();
document.all ['printbutton'].visible = true;
}


Something like that.
 
document.print()

seems doesn't pop up any printing window for above codes, that means the suggestion seems doesn't work ...
 
Back
Top