且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

打印aspx页面的内容

更新时间:2023-12-01 23:03:22

在Javascript中有一个打印方法,您几乎可以做到.
there''s a print method in Javascript,that''s about all you can do.


看看这篇文章:
如何在ASP.NET 2.0中打印 [
Have a look at this article:
How to Print in ASP.NET 2.0[^]


我有这个需要对此进行编码.但是,上面的两个"解决方案是我发现这样做的唯一方法.问题出在视图状态"附近.页面加载后,将设置视图状态,并且如果用户需要填写某些项目,然后您希望允许它们打印,哎呀,您就拥有了视图状态陷阱.因此,要在页面加载后并在用户填写一些表单数据后打印页面,那么.
1.将页面放在那里供用户输入.
2.使用postbackurl打印按钮调用asp页面. target = _blank,弹出一个窗口.
3.在该新页面加载中,使用previous.page填写数据.
4.从这里您可以使用所需的任何方法,例如解决方案2中的ASP文章,也可以使用解决方案1中的JavaScript document.print().对于这两者,您都希望在页面的body标签中有一个"onload print call".

某种涉及,问题源于页面加载后的"viewstate".您可能可以编写一些代码来更改所有项目的viewstate值,但是,破解者的时间比我现在要多.
I have this need to code this. However, the "two" solutions above are about the only way I have found to do this. The problem stems around the "viewstate". Once a page loads the view state is set, and if a user needs to fill out some items and then you want to allow them to print, oops, you have a view state gotcha. So for printing a page after page load, and after a user fills in some form data, then.
1. Put your page out there for user to input.
2. Print button calls asp page using postbackurl. target = _blank, making a popup.
3. On that new page load, use previous.page to fill in the data.
4. From here you can use any method you want, Like that ASP article in Solution #2 or you can use the JavaScript document.print() like Solution #1. And for both you want to have a "onload print call" in the body tag of the page.

Kind of involved, the problem stems from the "viewstate" after a page loads. You could probably code something to change viewstate values of all your items, but, crackers, that would be more time than I have right now.