KnowlegeZone.com, Share knowledge Gain knowledge
     

Home > ASP : Access Members / Properties of a user control

Article By: Saqib   Date: 9/24/2008

Access Members / Properties of a user control

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


Share |

Comments.
Comment/Solution Posted By: Saqib Khan    Date: 9/26/2008 3:51:00 AM
Above is true if you want to access members of a control which was loaded dynamically.


Pages :
Post Comment or Solution   OR   Sign in using Google/Aol/Yahoo/Msn/OpenID
Your Name:  
Your Email:  
Comments:
 
Please Verify:
(Type Answer)