views:

418

answers:

2

I have a ProductBox.ascx user control which I use as ItemTemplate for a DataList as i have to repeat it.Now that datalist in inside a seperate user control ProductGrid.ascx.There is a third usercontrol ProductPopUp.ascx.All these controls are on page User.aspx.

I want to access ProductBox.ascx from ProductPopUp.ascx. I want a loosely coupled solution to it.

Please mind ProductBox.ascx is inside other usercontrol

A: 

Create a Public property member on the nested control and set this as required for basic passing in data/values.

Edit: If these controls are repeated etc you can then set these new properties like setting other Controls using 'FindControl' and getting a reference to the UserControl.

Is this what you're after?

Mark Redman
There is a public property inside ProductBox.ascx which contains all the info which i want. I am not able to access ProductBox.ascx as it is inside other user control.I think i can find it using recursive findcontrol but again that wont be the best solution.
Rohit
A: 

I understand your desire for loose coupling as user controls ideally should be solely responsible for their appearance. However I can imagine circumstances where parent controls need to dictate their childrens' behavior.

You could bubble the DataList's data binding event up to the parent page and then manipulate each product. Just try to minimize the complexity of the interface between the parents & kids putting as much business logic inside the product controls as you can.

David Peters