Hi TS,
From your description, you're developing a custom web server control and
the custom control will need to get reference to another control(on the
same page) at runtime so as to retrieve some property value, correct?
Based on my experience, for this scenario, you can consider use the
following means to locate external control:
** If the control is at the top level of the aspx page, you can directly
use "Page.Form.FindControl" to locate the control in the HtmlForm's control
collection
** Or if the control will always be put in the same
container(NamingContainer) of your customer control, you can use the
following code to locate the external control within the same parent
namingcontainer:
this.NamingContainer.FindControl("controlid");
#note that what you need to use is the "ID" (not clientID or uniqueID) of
the target control you want to locate
Actually, generally, you do not need to loop all the controls collection on
the page(every controls) and it's not realistic, ony the Namingcontainer is
enough, just like what the Validator controls do(find the ones they'll
validate).
In addition, for the "IDReferencePropertyAttribute", it is mainly used for
design-time UI to help choose a control from the same namingcontainer, but
it won't help at runtime.
Hope this helps. If there is any further questions on this, please feel
free to let me know.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.