Method of passing the value between two pages

zhaozj2021-02-16  98

The control data of the TEXTBOX is transmitted between the WebForm1 and the WebForm2 page, the code is as follows:

public class WebForm1: System.Web.UI.Page {protected System.Web.UI.WebControls.TextBox TextBox1; protected System.Web.UI.WebControls.TextBox TextBox2; protected System.Web.UI.WebControls.Button Button1; private void Page_load (Object Sender, System.EventAndargs E) {// Place the user code here to initialize the page}

Public String text1 {get {return this.textbox1.text;}}

Public string text2 {get {return this.textbox2.text;}}

#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///

/// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// private () {this.button1.click = new system.eventhandler (this.button1_click); this.load = new system.eventhandler (this.page_load);

} #Endregion

Private void button1_click (object sender, system.eventargs e) {server.transfer ("Webform2.aspx");

Public class webform2: system.Web.ui.page {private void page_load (object sender, system.eventargs e) {// Place user code here to initialize page Webform1 WF1; WF1 = (WebForm1) contert.handler;

Response.write (wf1.text1 wf1.text2);}

#Region Web Form Designer Generated Code Override Protected Void OnNit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.onit (e);} ///

/// Designer Supports the required method - Do not use the code editor to modify the // / this method. /// private () {this.load = new system.eventhandler (this.page_load);} #ENDREGON}

转载请注明原文地址:https://www.9cbs.com/read-10334.html

New Post(0)