Asp.net打印页面上的图像按钮单击. [英] Asp.net Print the page on image button click.
本文介绍了Asp.net打印页面上的图像按钮单击.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我必须在窗口上打印3个图像按钮的.aspx页面.这些是打印",导出到Excel"和关闭".
当我单击打印图像"按钮时,它还将在该页面上打印按钮.我正在使用此代码进行打印:
Hello,
I have to print .aspx page on which i have 3 image buttons on the window. these are Print,Export to Excel and Close.
When i click on print image button, then it also print buttons on that page. I am using this code for printing :
imgBtnPrint.Attributes.Add("onclick", "window.print();");
该怎么做?
在此先感谢
how to do this ?
Thanks in advance
推荐答案
script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint =
window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
<div id="divPrint">
//print all from this content
</div>
<asp:button ID="imgBtnPrint" onClick="javascript:CallPrint('divPrint');"
Runat=Server /></div>
使用此功能,
use this,
<head runat="server">
<title></title>
<style type="text/css" media="screen">
.button
{
border:1px;
}
</style>
<style type="text/css" media="print">
.button
{
display:none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<img src="Upload/WaterMarkImages/Chrysanthemum.jpg" height="400px" />
<asp:button id="imgBtnPrint" onclientclick="javascript:window.print();" runat="Server" cssclass="button" xmlns:asp="#unknown">
Text="Print" />
</asp:button></div>
</form>
</body>
希望对您有帮助.
如果有帮助,别忘了将其标记为答案. :)
hope this will help you.
And Don''t forget to mark as answer if it helps. :)
这篇关于Asp.net打印页面上的图像按钮单击.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文