Click here to Skip to main content
15,746,064 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello frens, i have this question

i have a user control inside another user control. now i want to retrieve that nested user controls control value. what should i do

my user control is uc1 and it has uc2 user control nested.

i want to get the uc2 value in ex.aspx page which has uc1 user control.

please help

This is the same as accesing data on a form opened by another form - it locks the design of the controls together and prevents changes being made with considering their effect on the outside world.

Instead, create a property in the outer control, which returns the info you want. It can get it from it's inner control or not as it's design decides - but the outside world doe not need to be aware of the fact.
This makes your program both cleaner, and a lot more maintainable.
Share this answer
In your first user control, create a property and parse the second user control.

such as :
public class uc1 : UserControl
   public UserControl uc2{get; set;}

   // of your code here

public class uc2 : Usercontrol

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900