Design time control retrieval.

P

Paul

Hi All,

I have a control on a page that is a listing control.
It is feed by other controls on the page.

I am trying, at design time, to detect any controls that are associated
with my list control.

I am currently using the IReferenceService here is my code.

StringBuilder sbOut = new StringBuilder();

//IReferenceService iRef =
this.Site.GetService(typeof(IReferenceService)) as IReferenceService;
IReferenceService iRef =
this.Site.GetService(typeof(IReferenceService)) as IReferenceService;

Object[] controls = iRef.GetReferences(typeof(IControl));//
as IControl[];

sbOut.Append("<ul>");

sbOut.Append("<li>");

sbOut.Append( this.Page.Controls.Count );

sbOut.Append("</li>");

for (int iLoop = 0; iLoop < controls.Length; iLoop++)
{
IControl ctrl = (IControl)controls[iLoop];

string sName = ((IControl)ctrl).displayName;
string sGroupName = ((IControl)ctrl).GroupName;

// If the control is part of a group for the control
if (ctrl.GroupName != "" &&
(this.groupNames.IndexOf(ctrl.GroupName) > -1))
{
sbOut.Append("<li>Header : ");
sbOut.Append(ctrl.displayName);
sbOut.Append("</li>");

}
}

sbOut.Append("</ul>");

//lblOut.Text = sbOut.ToString();

return sbOut.ToString();

My problem is that it can ONLY see controls that appear BEFORE it in
the page.
Does anyone know how I might get around this?
 

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

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top