Refer to a custom property of a dynamically loaded user control

Discussion in 'ASP .Net Building Controls' started by Bryan Holland, Nov 17, 2003.

  1. 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
     
    Bryan Holland, Nov 17, 2003
    #1
    1. Advertising

  2. "Bryan Holland" <> wrote in message
    news:...
    > 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

    --
    Dave Rothgery
     
    Dave Rothgery, Nov 17, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page