• HTML页面做中间页跳转传递参数


         在web项目开发中,我们经常会从一个页面 传递大量的参数到另外一个页面,当参数很多的时候我们不能通过url直接传递过去,因为这样传递的参数有限,那么有木有其他的方法呢,当然有。我们可以用一个html页面作为中间页,把传递到HTML页面的数据通过post 请求 post到另外一个ASPX页面。实现在ASP.NET中实现跨页面大批量数据传递。废话少说,直接上代码:

          父页面:

       

     1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebAppTest.index" %>
     2 
     3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     4 
     5 <html xmlns="http://www.w3.org/1999/xhtml">
     6 <head runat="server">
     7     <title>父页面</title>
     8     <script language="javascript" type="text/javascript">
     9         function ShowDividePage() {
    10                 var params = new Object();
    11                 params.Keys = "1234567890";
    12                 params.Code = "qwertyuioplkjhgfdsazxcvbnm";
    13                 var sFeature = "dialogWidth:500px; dialogHeight:250px;center:yes;help:no;resizable:no;scroll:auto;status:no";
    14                 var url = "Pop.htm?sysid=" + Math.random();
    15                 window.showModalDialog(url, params, sFeature);
    16         }
    17     </script>
    18 </head>
    19 <body>
    20     <form id="form1" runat="server">
    21     <div>
    22     <input type="button" id="btn_Show" value="弹出" onclick="ShowDividePage();" />
    23     </div>
    24     </form>
    25 </body>
    26 </html>


    HTML中间页:

    <!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>
        <title>HTML中间页</title>
        <script language="javascript" src="Scripts/jquery-1.4.1.min.js"></script>
        <script type="text/javascript" language="javascript">
            $(document).ready(function () {
                window.name = "submitForm";
                var keys = window.dialogArguments.Keys;
                var code = window.dialogArguments.Code;
                $("#hdKeys").val(keys);
                $("#hdCode").val(code);
                $("#submitForm").submit();
            });
        </script>
    </head>
    <body>
    <form id="submitForm" action="Show.aspx" method="post" target="submitForm">
        <input type="hidden" id="hdKeys" name="hdKeys" />
        <input type="hidden" id="hdCode" name="hdCode" />
        </form>
    </body>
    </html>

    接收参数 子页面:

    直接在page_Load事件中接收:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    namespace WebAppTest
    {
        public partial class Show : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                string keys = Request.Form["hdKeys"];
                string Code = Request.Form["hdCode"];
                Response.Write(keys);
                Response.Write(Code);
            }
        }
    }

    效果如下:

     点我下载

  • 相关阅读:
    经验光照模型整理
    桥接模式下主机ping不通虚拟机,虚拟机能ping主机?kdump failed
    Vue项目目录结构分析
    interface{} 指针 bool 取值
    mac read-only file
    01Prism WPF 入门实战
    C#实现约瑟夫环数学问题
    SqlServer根据某列来分组后,再依据另一列来排序,选取第一行,后再依据另一列进行筛选,之后再统计数量
    2.算法分析-时间复杂度和空间复杂度
    1.数据结构和算法概述
  • 原文地址:https://www.cnblogs.com/suizhouqiwei/p/2733976.html
Copyright © 2020-2023  润新知