asp.net中的问题,请帮帮我 [英] problem in asp.net please help me

查看:69
本文介绍了asp.net中的问题,请帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中单击按钮时打印命令

how to print command on button click in asp.net

推荐答案

根据您的要求,不清楚您要尝试的是什么你被困在哪里
对于Web applicaton,打印代码必须在客户端.

您可以在代码后面编写与打印相关的代码,然后将其注入到页面中:
如何在ASP.NET 2.0中打印 [
Based on what you ask, it''s not too clear on what specifically you are trying and where are you stuck.
For Web applicaton, print code has to be on client side.

Either you can write your print related code in code behind and then inject it into the page:
How to Print in ASP.NET 2.0[^]

OR using JavaScript directly on the page itself, like:
function CallPrint()
{
  var printContent = document.getElementById('<%= pnlToPrint.ClientID %>');
  var printWindow = window.open("", "Print Panel", ‘left=50000,top=50000,width=0,height=0′);
  printWindow.document.write(prtContent.innerHTML);
  printWindow.document.close();
  printWindow.focus();
  printWindow.print();
  printWindow.close();
}


<asp: Panel runat="server" id="pnlToPrint" >
  <table>
    <tr>
      <td>
         Your data
      </td>
    </tr>
  </table>
</asp: Panel>

<input type="button" value="Print"  onclick="CallPrint();" />


这篇关于asp.net中的问题,请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆