zoukankan      html  css  js  c++  java
  • HTML页面做中间页跳转传递参数

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

          父页面:

    View Code
     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中间页:

    View Code
     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4     <title>HTML中间页</title>
     5     <script language="javascript" src="Scripts/jquery-1.4.2.min.js"></script>
     6     <script type="text/javascript" language="javascript">
     7         $(document).ready(function () {
     8             window.name = "submitForm";
     9             var keys = window.dialogArguments.Keys;
    10             var code = window.dialogArguments.Code;
    11             $("#hdKeys").val(keys);
    12             $("#hdCode").val(code);
    13             $("#submitForm").submit();
    14         });
    15     </script>
    16 </head>
    17 <body>
    18 <form id="submitForm" action="Show.aspx" method="post" target="submitForm">
    19     <input type="hidden" id="hdKeys" name="hdKeys" />
    20     <input type="hidden" id="hdCode" name="hdCode" />
    21     </form>
    22 </body>
    23 </html>

       接收参数 子页面:

    直接在page_Load事件中接收处理:

    View Code
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Web;
     5 using System.Web.UI;
     6 using System.Web.UI.WebControls;
     7 
     8 namespace WebAppTest
     9 {
    10     public partial class Show : System.Web.UI.Page
    11     {
    12         protected void Page_Load(object sender, EventArgs e)
    13         {
    14             string keys = Request.Form["hdKeys"];
    15             string Code = Request.Form["hdCode"];
    16             Response.Write(keys);
    17             Response.Write(Code);
    18         }
    19     }
    20 }

    效果如下:

  • 相关阅读:
    30个实例详解TOP命令
    CentOS6 启动流程图文解剖
    Linux常用性能检测命令解释
    Linux 多核下绑定硬件中断到不同 CPU(IRQ Affinity) 转
    linux系统中如何查看日志 (常用命令2)
    Linux下常用的shell命令记录1
    python import as from
    内存的大小端模式
    opencv笔记1
    代码不仅仅考虑性能
  • 原文地址:https://www.cnblogs.com/QLJ1314/p/2792297.html
Copyright © 2011-2022 走看看