Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Part III: ASP.NET Controls > Design-Time Support for Custom Controls - Pg. 509

509 Chapter 15. Design-Time Support for Custom Controls In this chapter: The Design-Time Architecture in .NET Design-Time Attributes Rendering Types Custom Designers Conclusion 594 596 604 619 628 A server control has two distinct sets of functionality--run-time and design-time capabilities. Run- time capabilities show up when the control is embedded in a page and served to the browser. Design-time capabilities integrate with a visual designer such as Microsoft Visual Studio 2005 and allow the programmer to configure the appearance and behavior of the control in a declarative and WYSIWYG (what-you-see-is-what-you-get) manner. Like standard and built-in controls, Microsoft ASP.NET custom controls can be architected to integrate with the host designer. All controls inherit some basic design-time capabilities from the base class Control . For example, all controls can be dragged from the toolbox and dropped onto a Web Form, and all controls, when selected within the designer, cause their properties to display in the Properties window. The design- time behavior of a control can be enhanced in three ways: setting predefined attributes, defining custom editors for properties, and adding a made-to-measure designer. We'll review the charac- teristics and the caveats of these three types of extensions in the context of the sample controls developed in the previous chapters. Before going any further, though, it's important to know that adding design-time features to a server control is optional. The Control class, from which all controls inherit directly or indirectly, already provides a base set of capabilities. These features are enough to make controls usable within a visual designer, but they're not necessarily enough to provide a rich (or even a decent) user expe- rience and to make the controls look like professional components. The Design-Time Architecture in .NET In the Microsoft .NET Framework, a designable component is a class that implements the ICom- ponent interface--for example, the Control class. The IComponent interface has just one property --named Site-- which corresponds to an object that implements the ISite interface. Sites bind a component to a container and enable communication between them. In addition, a site allows the container to manage its components and acts as a repository for container-specific, per-component information, such as the component name and attributes. Note