somewhere on the net, I found this little method and guess what, my control
shows, but FindControl does not find it... Should I create my own
FindControl method?
here's the method I found :
private string IterateThroughChildren(Control parent)
{
StringBuilder sb = new StringBuilder();
foreach (Control c in parent.Controls)
{
if (c.UniqueID != null)
{
sb.Append("<li>" + c.UniqueID.ToString() + "</li>");
if (c.Controls.Count 0)
{
sb.Append("<ul>");
sb.Append(IterateThroughChildren(c));
sb.Append("</ul>");
}
}
}
return sb.ToString();
}
thanks
ThunderMusic
"ThunderMusic" <NO.danlat.at.hotmail.com.SPAMa écrit dans le message de
news: %23QmHPg16GHA.4428@TK2MSFTNGP02.phx.gbl...
Quote:
Hi,
I have a custom WebControl. I fire an event and send, as the EventArg,
another WebControl that contains sub controls (ParseChildren(true))... It
can contain anything, but I want to find one control... Let's say the
control I want to find is "myControl". So I call
e.theObject.FindControl("myControl"); It always returns null and I know
the name of the control is good (that's the ID I gave it, is it possible
it has changed because it's the child of a WebControl?). When I look at
"theObject" in the Watch window, I got to it's base (WebControl), the to
the "Controls" property, then to the non-public fields to find the
collection of controls it contains and I find my object with the name I
want...
>
The question is... Is there a way for the FindControl function not to find
a control contained in the Controls collection? It's there for sure, why
FindControl does not find it?
>
thanks
>
ThunderMusic
>