Page between the page (continued)

xiaoxiao2021-03-06  181

Page between the page

Method 1: Plus a line in the HTML code of the received page: <% @Reference Page = "WebForm1.aspx"%> Webform1 fp = (WebForm1) Context.handler; this.textBox1.text = fp.name; // name is PUBLIC variable on the first page

Context provides access to the entire current context (including requested object). You can use information between this class sharing page.

Method 2: GET mode is sending page public int sum = 0;

INT i = int.parse (this.textBox1.text) * 2;

Server.Transfer ("Webform2.aspx? Sum =" i);

Receive page this.TextBox1.text = request ["sum"]. Tostring (); or this.textBox1.text = request.params ["SUM"]. Tostring (); this.textBox1.text = request.querystring [" Sum "];

Method 3: Global variable

Send Page: Application ["SUM"] = this.TextBox1.text; Server.Transfer ("WebMM2.ASPX");

Receive page: this.TextBox1.text = (string) Application ["Sum"];

Application is essentially a collection of all files in the entire virtual directory. If you want to use a variable value throughout the application, the Application object will be the best choice.

Use session [""] by session [""]

Method 4:

Send Page: 1. Define static variables: public static string str = ""; 2. Str = this.textBox1.text; server.transfer ("Webform2.aspx"); Receive page: 1. Introduced the first page Namespace : Using WebApplication1; 2 this.textBox1.text = Webform1.STR;

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

New Post(0)