Webform_1.aspx contents are as follows:
Copy Code code as follows:
<%@ page language= "C # autoeventwireup=" true "codebehind=" WebForm_1.aspx.cs "inherits=" pages are passed values. Webform_1 "%>
<! 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>
</head>
<body>
<form id= "Form1" runat= "Server" >
<div>
<asp:table id= "tablelogin" runat= ' server ' >
<asp:TableRow>
<asp:TableCell><label> username:</label></asp:tablecell>
<asp:tablecell><asp:textbox id= "UserName" runat= "Server" width= "150px" ></asp:textbox></ Asp:tablecell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><label> Password:</label></asp:tablecell>
<asp:tablecell><asp:textbox id= "PassWord" runat= "Server" width= "150px" ></asp:textbox></ Asp:tablecell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell><label> authentication Password:</label></asp:tablecell>
<asp:tablecell><asp:textbox id= "confimpwd" runat= "Server" width= "150px" ></asp:textbox></ Asp:tablecell>
</asp:TableRow>
<asp:TableRow>
<asp:tablecell><asp:button id= "Confirm" runat= "Server" text= "confirm" width= "50px" onclick= "Confirm_click"/ ></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
The Webform_2.aspx page is as follows:
Copy Code code as follows:
<%@ Reference page= "~/webform_1.aspx"%>
<%@ page language= "C # autoeventwireup=" true "codebehind=" WebForm_2.aspx.cs "inherits=" pages are passed values. Webform_2 "%>
<! 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>
</head>
<body>
<form id= "Form1" runat= "Server" >
<div>
</div>
</form>
</body>
</html>
WebForm_1.aspx.cs files are as follows:
Copy Code code as follows:
Using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace page Transfer value
{
public partial class WebForm_1:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
}
public string un//get user name
{
Get
{
return username.text;
}
}
public string pwd//get password
{
Get
{
return password.text;
}
}
public string conpwd//get a confirmation password
{
Get
{
return confimpwd.text;
}
}
///<summary>
///The value to the Webform_2.aspx page
///</summary>
///<param name= "Sender" ></param>
///<param name= "E" ></param>
protected void Confirm_click (object sender, EventArgs e)
{
//1:querystring Page Transfer value
//string url = "webform_2.aspx?un=" + Username.text + "&userpassword=" + Password.text + "&conpwd=" + Confim Pwd. Text;
//response.redirect (URL);
//2:session Transfer Value
//session["un"] = username.text;
//session["pwd"] = Password.text;
//session["conpwd"] = Confimpwd.text;
//server.transfer ("webform_2.aspx");
//3: Using a Cookie object to pass the value
//httpcookie cookie_name = new HttpCookie ("un");
//cookie_name. Value = Username.text;
HttpCookie cookie_pwd = new HttpCookie ("pwd");
//cookie_pwd. Value = Password.text;
//httpcookie cookie_conpwd = new HttpCookie ("Conpwd");
//cookie_conpwd. Value = Confimpwd.text;
//response.appendcookie (cookie_name);
//response.appendcookie (COOKIE_PWD);
//response.appendcookie (COOKIE_CONPWD);
//server.transfer ("webform_2.aspx");
//4: Use the Application object to pass a value, similar to the session pass value, scope global All users
//application["un"] = username.text;
//application["pwd"] = Password.text;
//application["conpwd"] = Confimpwd.text;
//response.redirect ("webform_2.aspx");
Server.Transfer ("webform_2.aspx");
}
}
}
WebForm_2.aspx.cs files are as follows:
Copy Code code as follows:
using System;
Using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace page Transfer value
{
public partial class WebForm_2:System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
//querytransfer ();
//sessiontransfer ();
//cookietransfer ();
//applicationtransfer ();
Transfer ();
}
public void Querytransfer ()//Receive QueryString value, from webform_1 page value
{
string strusername = request.querystring["un". ToString ();
string strpassword = request.querystring["UserPassword"]. ToString ();
string strpwd = request.querystring["Conpwd"]. ToString ();
Response.Write ("User name" + strusername + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd);
}
public void Sessiontransfer ()//receives the session pass value, from the value of the Webform_1 page
{
string strusername = session["un". ToString ();
string strpassword = session["pwd"]. ToString ();
string strpwd = session["Conpwd"]. ToString ();
Response.Write ("User name" + strusername + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd);
session.remove ("un");
session.remove ("pwd");
session.remove ("conpwd");
}
public void Cookietransfer ()//Receive a cookie to pass the value from the Webform_1 page value
{
string strusername = request.cookies["un". Value.tostring ();
string strpassword = request.cookies["pwd"]. Value.tostring ();
String strpwd = request.cookies["Conpwd"]. Value.tostring ();
Response.Write ("User name" + strusername + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd);
}
public void Applicationtransfer ()//Receive application value, from webform_1 page value
{
Application.Lock ();
string strusername = application["un". ToString ();
string strpassword = application["pwd"]. ToString ();
string strpwd = application["Conpwd"]. ToString ();
Application.UnLock ();
if (strpassword!= strpwd)
{
Response.Write ("The password you confirmed is wrong, please re-enter!") <br/> ");
Server.Transfer ("webform_1.aspx");
}
Response.Write ("User name" + strusername + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd);
}
The public void Transfer ()//transfer the value, from the value of the Webform_1.aspx page
{
webform_1 wf1;
wf1 = (webform_1) Context.Handler;
string strusername = wf1.un;
string strpassword = Wf1.pwd;
string strpwd = Wf1.conpwd;
Response.Write ("User name" + strusername + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd);
}
}
}
I have a limited level, but also invite friends to advise!