[英]How can i print a page in asp.net without master page and to change color schemes of the page?
i have made a page in asp.net, i have a costing calculator which has more than 50 fields, dependent on each other, one is the result of previous two and like that, i want my page to be printed in a well manner, and the header of the page which is in master page should not be in print, also the color schemes i want to adjust, let me know the best solution for this which .net provides我在 asp.net 中做了一个页面,我有一个成本计算器,它有 50 多个字段,相互依赖,一个是前两个的结果,就像这样,我希望我的页面打印得很好,并且母版页中的页面的 header 不应打印,还有我要调整的配色方案,让我知道 .net 提供的最佳解决方案
Put the content inside <div id="divid">YOUR CONTENT NEEDS TO BE PRINTED</div>
将内容放入
<div id="divid">YOUR CONTENT NEEDS TO BE PRINTED</div>
Then call the javascript function on button click which will print the selected area or only html of div.然后在单击按钮时调用 javascript function 将打印所选区域或仅打印 div 的 html。 pass the id of div on calling javascript function.
在调用 javascript function 时传递 div 的 id。
function CallPrint(var strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=10,top=10,width="450",height="250",toolbar=1,scrollbars=1,status=0');
WinPrint.document.write("<html><head><LINK rel=\"stylesheet\" type\"text/css\" href=\"css/print.css\" media=\"print\"><LINK rel=\"stylesheet\" type\"text/css\" href=\"css/print.css\" media=\"screen\"></head><body>");
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.write("</body></html>");
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
return false;
}
Call CallPrint('DivGrid');" on onclick() of button or use below: but.Attributes.Add("OnClick", "return CallPrint('DivGrid');");
在按钮的 onclick() 上调用 CallPrint('DivGrid');" 或在下面使用:
but.Attributes.Add("OnClick", "return CallPrint('DivGrid');");
I know that question has been asked a long time ago, however there is no accepted suggestion.我知道很久以前就有人问过这个问题,但是没有被接受的建议。 So here my approach for friendly print version when using Master page.
所以这里是我使用母版页时友好打印版本的方法。
You can make a new printable page version, which doesn't include a header.您可以制作新的可打印页面版本,其中不包含 header。 This version can also have the layout you need.
这个版本也可以有你需要的布局。
Nothing to do with.Net and everything to do with a print stylesheet.与.Net 无关,与打印样式表无关。 You can create a stylesheet which will only work for when the page is printed.
您可以创建仅在打印页面时才有效的样式表。 And you can change everything from what displays to postion to colours.
您可以更改从显示内容到位置再到颜色的所有内容。
Use:利用:
<LINK rel="stylesheet" type"text/css" href="print.css" media="print">
Note media="print"
means it'll be used for printed pages.注意
media="print"
表示它将用于打印页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.