I have written a webcustomcontrol (NOT ascx).
I have 10 on a web page and want to find them in the code behind.
I have tried using foreach, but I am not sure what collection to search in.
Does anyone know the answer to this question? Is it possible?
Thanks in advance,
Lee
Loading
LeePosted Aug 23, 2005, 6:39 AM
I have found out how to do it, but I have a problem
[CODE]
Type t; foreach (Control oPart in this.Controls) // Loop through the controls on the page.
{
t = typeof(SMDCMS.WebPart); if (t.FullName.IndexOf("WebPart")>0){
PropertyInfo[] p = t.GetProperties(); foreach(PropertyInfo y in p){
if(y.Name == "Channel"){
y.SetValue("Channel", c, null); //Here is the problem!!}
}
}
}
[/CODE]
get this error:
Object does not match target type.
Please help!
Thanks
Lee