|
Sometimes we use LoadControl Method to Load a usercontrol dynamically and then we attached it to a place holder within our aspx page. once we have user control attached. then how can we access its members dynamically?
Solution is easy, simply add a reference to the user control and then access its class name within code-behind, below is a example.
<% @ Reference Control="../UC/Popage.ascx" %> (Thats in aspx page)
Dim myctr As Popage
myctr = CType(LoadControl("../UC/PoPage.ascx"), Popage)
myPo.Controls.Add(myctr)
PoPage is a Class name within PoPage.ascx User Control. Now we can easily do "myctr.myProperty" etc.
- Saqib A Khan
|