In web project development, we often pass a large number of parameters from one page to another. When there are many parameters, we cannot directly pass them through the url, because the parameters passed in this way are limited, there are other methods, of course. We can use an html page as the intermediate page to post the data transmitted to the HTML page to another ASPX page through the post request. Implement mass data transfer across pages in ASP. NET. Put the following code directly:
Parent page:
Copy to ClipboardReference: [www.bkjia.com] <% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "index. aspx. cs" Inherits = "WebAppTest. index" %>
<! 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> parent page </title>
<Script language = "javascript" type = "text/javascript">
Function ShowDividePage (){
Var params = new Object ();
Params. Keys = "1234567890 ";
Params. Code = "qwertyuioplkjhgfdsazxcvbnm ";
Var sFeature = "dialogWidth: 500px; dialogHeight: 250px; center: yes; help: no; resizable: no; scroll: auto; status: no ";
Var url = "Pop.htm? Sysid = "+ Math. random ();
Window. showModalDialog (url, params, sFeature );
}
</Script>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Input type = "button" id = "btn_Show" value = "pop-up" onclick = "ShowDividePage ();"/>
</Div>
</Form>
</Body>
</Html>
HTML intermediate page:
Copy to ClipboardReference: [www.bkjia.com] <! 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 intermediate page </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>
Receiving parameters subpage:
Directly receive in the page_Load event:
Copy to ClipboardReference: [www.bkjia.com] 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 );
}
}
}
The effect is as follows:
Download instance:HTMLPop_bkjia.com.rar