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. Advertising

  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. 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.
Similar Threads
  1. Replies:
    0
    Views:
    2,213
  2. Jeff Rodriguez
    Replies:
    23
    Views:
    1,086
    David Schwartz
    Dec 9, 2003
  3. Faizan Ahmed
    Replies:
    1
    Views:
    271
    John Saunders
    Jan 4, 2005
  4. Replies:
    0
    Views:
    194
  5. Faizan Ahmed
    Replies:
    1
    Views:
    346
    John Saunders
    Jan 4, 2005
Loading...

Share This Page