Refer to a custom property of a dynamically loaded user control

B

Bryan Holland

I have an app where I dynamically load a user control based on the type of
data it is rendering. There are some standard custom properties that I want
to access.

How do I refer to a custom property of a dynamically loaded user control?

Thanks

B
 
D

Dave Rothgery

Bryan Holland said:
I have an app where I dynamically load a user control based on
the type of data it is rendering. There are some standard custom
properties that I want to access.
How do I refer to a custom property of a dynamically loaded user control?

I'm not sure if this will help you (depends on where in the control life
cycle you need to access properties at), but what I've done to set user
control properies is something like this...

[in VB.NET, where I'm loading a user control in response to a button click,
then adding it to a PlaceHolder]

Private Sub myButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles myButton.Click
Dim ctrl As myUserCtrl

ctrl = CType(Page.LoadControl("myUserCtrl.ascx"), myUserCtrl)
ctrl.myProperty = "value"

myPlaceHolder.Controls.Add(ctrl)
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top