How to access user control child controls

W

Waldy

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);
 
W

Waldy

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

public String Title
{
set { TitleText.Text = value; }
}
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top