• 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>
  • 相关阅读:
    List某字段相同时将其他字段数据相加
    【转】常见面试之机器学习算法思想简单梳理
    【转】R语言知识体系概览
    【转】聊聊HTTPS和SSL/TLS协议
    面试总结【1】
    【转】学习Python的19个资源
    【转】机器学习资料汇总
    Python小爬虫
    【转】python操作mysql数据库
    SQL语法
  • 原文地址:https://www.cnblogs.com/samsonhuang/p/2284607.html
Copyright © 2020-2023  润新知