ASP.NET Page Transfer Object - Server object Transfer ()

xiaoxiao2021-03-06  213

With the Transfer () method of the Server object, it receives a page object.

Let's take a look at this implementation:

Write the following code in an event of WebForm1.aspx: Server.Transfer ("WebForm2.aspx"); // Pass the page object next to get webform1 page objects in WebForm2.aspx.cs. If (context.handler is webform1) // determines whether it is transferred WebForm1, because there may be multiple delivery objects. {WebForm1 F1 = (WebForm1) Context.Handler; // Create a webform1 page object through context.handler, returns an Object Response.write ("Hey, I Get It With Context Handler ((TextBox) F1.FindControl ("TextBox1"))). TEXT "

"); ??} // Finally, by calling the FinControl () method of the WebForm1 object to find a text control named" TextBox1 "in WebForm1, you can also replace it with other controls, no matter which control is found. It must be forced to convert it to its type. In this example, it is TEXTBOX, and finally calls its property text, get the value of the TEXTBOX1, to achieve the effect of the value. This method is equally flexible, you can pass multiple page objects, Instead of transmission values, you can get the values ​​or other data of certain controls in this page object when you get the page object.

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

New Post(0)