zoukankan      html  css  js  c++  java
  • js打印小例

    Default2.aspx.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public partial class Default2 : System.Web.UI.Page
    {
    protected Dictionary<string, string> dic;
    protected void Page_Load(object sender, EventArgs e)
    {
    dic = new Dictionary<string, string>();
    dic.Add("1", "呵呵");
    dic.Add("2", "哈哈");
    }
    }

    Default2.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

    <!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></title>
    <script type="text/javascript">
    function printdiv(divid) {
    window.document.body.innerHTML = document.getElementById(divid).innerHTML;
    window.print();
    window.history.go(-1);
    };

    </script>
    </head>
    <body>

    <div>
    <select>
    <option value="">请选择</option>
    <%foreach (var item in dic)
    {%>
    <option value="<%=item.Key%>"><%=item.Value%></option>
    <% }%>
    </select>
    </div>
    <input id="btnPrint" type="button" value="打印" onclick="javascript:printdiv('divpr')" />
    <div id="divpr">
    <table width="300px">
    <%foreach (var item in dic)
    {%>
    <tr>
    <td><%=item.Key%></td>
    <td><%=item.Value%></td>
    </tr>
    <% }%>

    </table>
    </div>
    </body>
    </html>
  • 相关阅读:
    Ubuntu16.04上安装搜狗输入法
    RAM的分类
    解耦技巧——依赖注入!
    傻瓜式学Python3——列表
    Java Builder 模式,你搞懂了么?
    String 源码浅析(一)
    线上CPU100%?看看这篇是怎么排查的!
    生物医学工程SCI期刊投稿(转)
    免费下载文献
    泰山攻略
  • 原文地址:https://www.cnblogs.com/samsonhuang/p/2284607.html
Copyright © 2011-2022 走看看