Home All Groups Group Topic Archive Search About
Author
23 Mar 2005 6:25 PM
Dave Bailey via DotNetMonster.com
Is it possible to print a webfor datagrid and if so how?

Thanks,

Dave

--
Message posted via http://www.dotnetmonster.com

Author
24 Mar 2005 8:33 AM
Eliyahu Goldin
Dave,

There are 2 ways how to print: either from the browser menu or with
javascript window.print() call. Both will result in producing standard
browser's Print dialog. If you selected the grid prior to printing, you can
choose print selection. You can select grid programmatically in javascript.
There is no other way of printing a single control.

Eliyahu

Show quoteHide quote
"Dave Bailey via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:b17520332caa4c7188867c953e80fdb5@DotNetMonster.com...
> Is it possible to print a webfor datagrid and if so how?
>
> Thanks,
>
> Dave
>
> --
> Message posted via http://www.dotnetmonster.com
Author
24 Mar 2005 2:26 PM
Dave Bailey via DotNetMonster.com
Do you have a sample of the javascript code used for printing?

Many thanks for the response,

Dave

--
Message posted via http://www.dotnetmonster.com
Author
24 Mar 2005 2:33 PM
Eliyahu Goldin
window.print() is the only call used for printing. To operate with selection
use document.selection object.

Eliyahu

Show quoteHide quote
"Dave Bailey via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:b2a19373e7bb4c6bbc1d537c0229f6cf@DotNetMonster.com...
> Do you have a sample of the javascript code used for printing?
>
> Many thanks for the response,
>
> Dave
>
> --
> Message posted via http://www.dotnetmonster.com
Author
24 Mar 2005 10:31 PM
David Alpert
> There are 2 ways how to print: either from the browser menu or with
> javascript window.print() call. Both will result in producing standard

There are usually more than 2 ways to skin the cat, if you'll forgive
the metaphor...

If you are creative with your CssStyle attributes and stylesheets, you
can probably create a print stylesheet that will do the job:

http://www.meyerweb.com/eric/articles/webrev/200001.html
http://www.ericmeyeroncss.com/projects/06/
http://www.pmob.co.uk/faqcss/tutorial03/
http://www.yourhtmlsource.com/stylesheets/cssmediatypes.html

For example, build your page such that you can attach styles of
"display:none" to everything but the control you want to print.  For a
datagrid, you can even programmatically or declaratively style the
table, columns, rows, cells, etc such that you can selectively style
each separate element differently for print than for screen.

This way, when the user selects file->print, the browser uses the
print stylesheet and all they get on paper is your grid.

Of course, in ASP.NET, this kind of technique essentially makes it
easy to automate generating a more print-friendly page, or even
attaching different stylesheets on postback depending on what the user
wants to print...

(incidentally, check out eric meyer's various web sites for beautiful
examples of the power of adding creative CSS to sparse, clean, and
well-structured HTML:
- http://www.complexspiral.com/
- http://www.meyerweb.com/eric/css/
)