How to access user control child controls

Discussion in 'ASP .Net Web Controls' started by Waldy, May 8, 2008.

  1. Waldy

    Waldy Guest

    Hi there,
    I am loading some user controls and I want to populate the
    child controls within them, but can't access them. I doing the following in
    a loop. However the TitleText or other child controls are not available.
    They have the runat server tag.

    NoticeItem uc = (NoticeItem)Page.LoadControl("~/noticeitem.ascx");

    uc.TitleText = "Some text";

    e.t.c

    NoticeboardPanel.Controls.Add(uc);
     
    Waldy, May 8, 2008
    #1
    1. Advertisements

  2. Waldy

    Waldy Guest

    I got around the probem by adding some public properties to the user control
    like so:

    public String Title
    {
    set { TitleText.Text = value; }
    }
     
    Waldy, May 8, 2008
    #2
    1. Advertisements

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.
Similar Threads
  1. Replies:
    0
    Views:
    2,456
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,576
    David Schwartz
    Dec 9, 2003
  3. Ofer Zelig
    Replies:
    15
    Views:
    1,122
    Mark Rae
    Mar 28, 2007
  4. Ofer Zelig
    Replies:
    3
    Views:
    924
    Walter Wang [MSFT]
    Mar 28, 2007
  5. Chad Scharf
    Replies:
    3
    Views:
    1,119
    Chad Scharf
    Oct 18, 2007
  6. Faizan Ahmed
    Replies:
    1
    Views:
    504
    John Saunders
    Jan 4, 2005
  7. Replies:
    0
    Views:
    401
  8. Faizan Ahmed
    Replies:
    1
    Views:
    535
    John Saunders
    Jan 4, 2005
Loading...