Page between the page

xiaoxiao2021-03-06  47

Way 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 the first page of public variables

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

Method 2: GET method

Send a page

Public int sum = 0;

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

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

Receive pages

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 a page:

Application ["SUM"] = this.TextBox1.Text;

Server.Transfer ("Webform2.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.

Method 4:

Send a page:

1. Define static variables: public static string str = ""

2. Str = this.TextBox1.Text;

Server.Transfer ("Webform2.aspx");

Receive page:

1. Introduce the namespace of the first page: use WebApplication1;

2 this.TextBox1.text = Webform1.STR;

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

New Post(0)