I'm trying to create an AJAX component that contains a CollapsiblePanelExtender. Since the CPE is a child control of my control, the CPE's javascript $create statement is emitted after my component's $create statement. Thus, when the JS constructor for my component runs and tries to find the CPE, it can't find the CPE because it hasn't been created yet. One solution I've thought of is to attach on_load handlers in my initialize method, thereby postponing the fetching of the CPE until after load; another solution is to register a startup script that calls a method on my component to go find the CPE. Neither of these solutions seems clean. My question is, how are you supposed to make this sort of thing work?
A:
Don't try and find the CPE until your initialize method. Take its ID as a string property, and use $find to get the reference.
Another solution is to use the 'references' feature of $create, which you use from a script descriptor with AddComponentProperty -- pass in the ClientID of the CPE. The framework takes care of setting the actual reference to the property by using a two-pass technique, where they are all created first, then those references are set, avoiding any ordering issues.
InfinitiesLoop
2009-07-24 17:08:47