Methods used to operate user controls in Asp.net 2.0

Source: Internet
Author: User

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!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.