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>
  • 相关阅读:
    修改UISearchBar的Cancel按钮为中文等本地化问题
    Xcode6 运行程序后,右侧Debug区域的Memory显示空白解决方法
    vuec常用插件
    clipboard 实现复制
    vue 表单操作
    vue 常用功能和命令
    关闭警告&关闭eslint
    vue 添加 fastclick的支持
    url编码函数encodeURI和encodeURIComponent
    jsencrypt加解密 &&cryptico
  • 原文地址:https://www.cnblogs.com/samsonhuang/p/2284607.html
Copyright © 2011-2022 走看看