Several ways of pages

xiaoxiao2021-03-06  50

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 the public variable

Context® Provides access to the entire current context (including request 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:

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;

this.TextBox1.text = Webform1.STR;

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

New Post(0)