Webform_1.aspx content is as follows:
<%@ page language= "C #" autoeventwireup= "true" codebehind= "WebForm_1.aspx.cs" inherits= "pages pass values. Webform_1 "%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The Webform_2.aspx page is as follows:
<%@ Reference page= "~/webform_1.aspx"%> <%@ page language= "C #" autoeventwireup= "true" codebehind= "webform_2. Aspx.cs the "inherits=" page to pass the value. Webform_2 "%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The WebForm_1.aspx.cs file is 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 Pass value {public partial class WebForm_1:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs E {} public string un//get the user name {get {return username.text;}} public string pwd//get the password {get {return password.text;}} public string conpwd//Get confirmation password {get {return confimpwd.text;}}///<summary>///</summ to webform_2.aspx page ary>//<param name= "sender" ></param>///<param name= "E" ></param> protected void Confirm_ Click (object sender, EventArgs e) {//1:querystring page value//string url = "webform_2.aspx?un=" + Username.text + "&userpa Ssword= "+ Password.text +" &conpwd= "+ confimpwd.text; Response.Redirect (URL); 2:session value//session["un"] = username.text; session["pwd"] = Password.text; session["conpwd"] = Confimpwd.text; Server.Transfer ("webform_2.aspx"); 3: Use Cookie ObjectTransmit 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 Application object value, similar to session 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"); } } }
The
WebForm_2.aspx.cs file is 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 Pass value {public partial class WebForm_2:System.Web.UI.Page {protected void Page_Load (object sender, EventArgs E ) {//querytransfer ();//sessiontransfer ();//cookietransfer ();//applicationtransfer (); Transfer (); The public void Querytransfer ()//receives the QueryString value, and the value from the Webform_1 page is {string strusername = request.querystring["un"]. ToString (); String strpassword = request.querystring["UserPassword"]. ToString (); String strpwd = request.querystring["Conpwd"]. ToString (); Response.Write ("User name is" + strUserName + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd); The public void Sessiontransfer ()//receives Session value from the Webform_1 page with the value {string strusername = session["un"]. ToString (); String strpassword = session["pwd"]. ToString (); String strpwd = session["Conpwd"]. ToString (); Response.Write ("username is" + strusername + "<br/>" + "password is" + STRPASSWOrd + "<br/>" + "Confirm password" + strpwd); Session.remove ("un"); Session.remove ("pwd"); Session.remove ("Conpwd"); The public void Cookietransfer ()//receives the value of the cookie, the value from the Webform_1 page {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 is" + strUserName + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd); The public void Applicationtransfer ()//receives application value, from the value of the Webform_1 page {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 ("username" + strUserName + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd); The public void Transfer ()//transfer the value from the WebThe value of the form_1.aspx page {webform_1 wf1; wf1 = (webform_1) context.handler; string strusername = wf1.un; string strpassword = WF1.P wd string strpwd = Wf1.conpwd; Response.Write ("User name is" + strUserName + "<br/>" + "password is" + strpassword + "<br/>" + "Confirm password is" + strpwd); } } }
My level is limited, also please all friends advice!