By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,067 Members | 1,818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,067 IT Pros & Developers. It's quick & easy.

print method in Javascript

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Thu, 29 Apr 2004 21:41:04 -0700, "Machi"
<an*******@discussions.microsoft.com> wrote:
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.

Nov 18 '05 #2

P: n/a
document.print()

seems doesn't pop up any printing window for above codes, that means the suggestion seems doesn't work ...
Nov 18 '05 #3

P: n/a

"Machi" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
document.print();

seems doesn't pop up any printing window for above codes, that means the

suggestion seems doesn't work ...
Nov 18 '05 #4

P: n/a
Hi Machi,

you can take a look at the following link this may give you some hints
http://www.eggheadcafe.com/articles/20030627a.asp

Regards
Ashish M Bhonkiya
"Machi" <an*******@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
document.print();

seems doesn't pop up any printing window for above codes, that means the

suggestion seems doesn't work ...
Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.