I found that I can't use FindControl on an ID of a control of a control.
If I change the FindControl line from:
contentControl = CType(a.FindControl("Content"),Control)
to:
contentControl = CType(a.FindControl("_ctl0:Content"),Control)
it works.
The trace says _ctl0 is "ASP.ftsPage_ascx".
I was confused as to why it wouldn't be something like:
thePlaceHolder:Content.
I assume this is because this is a Control in the "thePlaceHolder" control.
Is there a way to give this an ID instead using the _ctl0 ID?
Thanks,
Tom
Hi,
I've explained FindControl in the past.
http://aspadvice.com/blogs/joteke/archive/2006/08/12/20546.aspx
If you are accessing a control outside of its naming container, you need to
use UniqueId or resolve to the naming container of the control (in this case
the parent of it) and then run FindControl against it. E.g using plain
FindControl looks for controls in the local naming scope. What defines a new
naming scope is if control implement an INamingContainer interface. ascx e.g
a user control is one such.
Controls IDs can be given if you are setting them up e.g on aspx or adding
dynamically in code. However, if they are controls generated by ASP.NET it's
harder to manage. For example autonumbering ctr0...ctrlN is used when
databound controls set up control hierarchies etc etc

Signature
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
>I found that I can't use FindControl on an ID of a control of a control.
>
[quoted text clipped - 103 lines]
>>
>> Tom
tshad - 31 Jul 2007 17:52 GMT
I read your post and it was pretty good.
I looked at the code again and tried this:
contentControl = CType(thePlaceHolder.FindControl("Content"),Control)
I was thinking that now I am now looking at the control "thePlaceHolder" as
the container but that still doesn't work.
My only problem with using ctl0:Content is that if I change the order that
something is loaded, this would change the control to something like
ctl1:Content.
Is there a better way to get the control?
Thanks,
Tom
> Hi,
>
[quoted text clipped - 123 lines]
>>>
>>> Tom