要打印.aspx页面。 [英] To print a .aspx page.
本文介绍了要打印.aspx页面。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello先生,
我有一个aspx页面,文本框中有数据,还有一个按钮确认onclick将它添加到数据库中。我想添加另一个按钮,它将整个页面打印为账单(在我的应用程序中)。
我尝试使用onclick =window.print();但是我以服务器错误结束了。
所以你可以建议解决方案。
谢谢和问候
Rajani
Hello Sir,
I have a aspx page, with data in the text boxes, and also a button "confirm" which onclick adds it to the database. I want to add a another button, which prints the entire page as a bill(as in my application).
I tried using onclick="window.print();" but i was ended with a server error.
So can you suggest the solution.
Thanks & Regards
Rajani
推荐答案
您需要使用OnClientClick,因为这是一个ASP.Net按钮。 OnClick实际上是你要运行的C#中的方法,但是window.print()是javascript,所以你需要使用OnClientClick。
You need to use OnClientClick because this is an ASP.Net button. OnClick is actually the method in C# that you want to run but window.print() is in javascript so you need to use OnClientClick instead.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style media="print" type="text/css">
#printButton { display: none; }
#pageHeader { display: none; }
#pageFooter { display: none; }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" onblur="window.print();" id="printButton" value="Print Page" />
<p id="pageHeader">Transaction Summary</p>
<p>This is some page.</p>
</div>
<p id="pageFooter">footer stuff</p>
</form>
</body>
</html>
这篇关于要打印.aspx页面。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文