I have three usercontrols uc1.ascx ,uc2.ascx ,UC_Combined.ascx
UC1 has one label control
UC2 has one Dropdownlist Control
UC_Combined is created by combining UC1 and UC2
Now I placed UC_Combined.ascx on my aspx page webForm1.aspx has one more Label servercontrol
Now when I run my webForm1.aspx page I can see see DropDown list and a Label
Now when I select an Item from dropdown list ,I want the value of the selection to display to the Label
Can some one suggest me how can I do this .
Easy. Implement a event on the uc containing the drop down like:
The selection changed handler of the dd then have to call OnDDSelectionChanged.
Register a handler onto that event in your page (aspx). This handler should then call something like ChangeText(text) on the second uc with the textbox. And the textbox is been updated.
So the communication between the uc's is driven by events and the page has the resposibility to wire the events up. The uc's are completely independent.
It's not best to create a dependency between parent and child controls. Something you should generally avoid. But, if you have to do it or in some way makes your life alot easier then there are a few techniques for achieving this while keeping the controls somewhat decoupled. I would suggest you do the following:
Think you got it?