When I was doing something two days ago, I wanted to access the methods in the user control. I don't know the specific method. The first step is to google it,
Find the following content:
| how to interact with user controls on pages |
The following is a solution
first, create a user control UC. ascx
place a label and set its value to test
This. label1.text = "test";
Add a method to the user control
Public void AA ()
{< br> This. label1.text = "the method for calling the user control on this page is successful ";
}< br> Create a webform to import this user control
<% @ register tagprefix = "AA" tagname = "BB" src = "UC. ascx "%>
place two buttons on the page
Add
(UC) This. findcontrol ("TOP ")). label1.t EXT = "the value of the control in the user control is successfully set on the page "; // This label1 is the label in the User Control
added to the event of the second button
(UC) This. findcontrol ("TOP ")). AA ();
the preceding two buttons complete the preceding two Operations respectively. In the preceding Code , UC indicates the class name of the user control (that is, the name of the user control). If not, add the name of the control. |
Because my platform is 2.0, you can find this in the designer. top. AA (); in this way, although it is a small improvement, but the Details determine the success or failure, it seems that ASP. NET 2.0 is still promising!