Printing Question

J

John Smith

How to print when the user clicks a button in ASP.Net application. Is it
possible to call print dialog so that the user can printer properties before
printing? My development environment is .Net 1.1.
Thanks for your answers.
John
 
G

Guest

Dear John,

You can use the window.print method.

<input type="button" value="Print this page" onClick="window.print()">

This would do.

Hope it helps.
 
J

John Smith

Thanks for your answer.
However I want to print only the grid data and data from textbox.
John
 
S

simon

Have you find your answer?

I have done it by opening new window with only grid inside, then
use window.print command and window.close command in window_onload event..

That is one way but I would like to know, is there any simplier way?

Thank you,
Simon
 
H

Hans Kesting

simon said:
Have you find your answer?

I have done it by opening new window with only grid inside, then
use window.print command and window.close command in window_onload event..

That is one way but I would like to know, is there any simplier way?

Thank you,
Simon

Different yes, simpler I don't know:
you can use a stylesheet with a special section specifically for printing.
There you can switch off the display of the unwanted parts of the page.
I think it had something to do with @media print { }

Hans Kesting
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Simon,

I just answered your other post, it's very simple in fact. Just drop me a
line if you still have problem

You know what, I better post the code once and for all :)

in the "parent page"

<DIV id="panel1" name="panel1">
... content to be printed
</div>
<input type="button" onclick="OpenPrinter()">

<script>
function OpenPrinter(){
//Open a new windows with out any decoration just
var wi = open("Statsprint.aspx","printrecord",
"width=760,height=600,menubar=no,resizable=no,scrollbars=yes,status=no,toolb
ar=no");
}
</script>


in the new window:

<script>
function FillPage()
{
var div = document.all["CONTENT"];
var origdiv = window.opener.document.all["Panel1"];

div.innerHTML = origdiv.innerHTML;

print();
close();
}
</script>
</head>
<body MS_POSITIONING="GridLayout" onload="FillPage();">
<form id="Statsprint" method="post" runat="server">
<span id="CONTENT">
</span>
</form>
</body>


If you still have doubt just drop me a line,


Cheers,
 
R

riny

i want to print a page (here billing page)
i have make a page (template billing form).
information i get from database.. (ex there are 50 person.. )
so i read one custinfo from database than send info to billing Page use query string. biling page than print to printer than looping back for other 49 person.
can it be done?? i use asp.net
please...
or there are other solution??
thanks..
please tell me to (e-mail address removed)

From http://www.developmentnow.com/g/8_2004_6_0_0_180243/Printing-Question.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top