由于工作的需要,要求打印网页。而且是网页中的指定内容。有点多次一举“可是这就是客户的需求!!~”(某高人语)。收集了两个比较合适的解决方法。
首先是用JAVASCRIPT,以下是函数

None.gif < script language = " javascript " type = " text/javascript " >
None.gif
<!--
None.gif
ExpandedBlockStart.gifContractedBlock.giffunction Button3_onclick() 
dot.gif {
InBlock.gifbdhtml
=window.document.body.innerHTML;
InBlock.gifsprnstr
="<!--startprint-->";
InBlock.gifeprnstr
="<!--endprint-->";
InBlock.gifprnhtml
=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
InBlock.gifprnhtml
=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
InBlock.gifwindow.document.body.innerHTML
=prnhtml;
InBlock.gifwindow.print();
InBlock.gif
ExpandedBlockEnd.gif}

None.gif
</ script >

应用时把要打印的内容放到<!--startprint-->和<!--endprint-->之间。
二是C# documment类和print类的实现:
由于百度空间不利于展示代码详情见:http://www.cnblogs.com/guodashao/archive/2006/08/16/478287.html