简体   繁体   中英

How to access a control under the UserControl of UserControl

I have a main page that built up from a few parent UserControls, and some of this parent UserControls are built up from multiple child UserControls.

Currently the issue that I'm facing is that, I need to access a RadioButtonList from the main page and that particular RadioButtonList is located in the child UserControl.

Main Page contains parent UserControl.

Parent UserControl contains child UserControl.

Child Usercontrol contains a RadioButtonList.

Please help.

Add a property to your custom user control to expose the inner control, as such:

public RadioButtonList RadioButtons { 
  get { return _radioButtons; }
}

Where the instance is named _radioButtons accordingly.

You can do this all the way up the hierarchy, though it would get messy with a deep composite structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM