Monday, March 26, 2012

Explaining the structure of Rating/Accordian Control

Are there any documentation or could anyonoe take the time to explain/document, or a step by step run through of creating controls similar to these two? Where the extender is 'dynamically' attached to a server control in the code?

Thanks and Regards.

Hi Inventisity,

Accordion,NoBot,Rating, andReorderList are all examples of controls that wrap extenders. This pattern is useful in situations where the extender requires the markup of the target control to be in a specific (and possibly lengthy) format. You write the server-side extender and client-side behavior as usual. You then create a control (by inheriting from something likeWebControl orPanel) that renders the appropriately formatted markup, dynamically create your extender/properties, and point yourproperties.TargetControlID atthis.ID (and hence the rendered markup). Following common practices for writing server controls, the extender and its properties are created in theCreateChildControls method (which we make sure is called before anywhere we access the extender/properties usingEnsureChildControls). Finally, the necessary properties are exposed on the control (and just passed off to the actual properties object).

I think this should give you an idea of what these controls are doing, but please post back if you have any other unanswered questions. If you plan on writing your own control that wraps extenders, keep an eye onwork item #1687 because it applies to all of these controls.

Thanks,
Ted

No comments:

Post a Comment