Chapter 10. Complex Properties and State Management


In Chapter 7, "Simple Properties and View State," we looked at simple properties ”that is, properties of primitive types and strings. We examined how the page framework automatically supports declarative page syntax (declarative persistence) for simple properties. We showed how to apply attributes that enable design-time support for properties in a visual design environment. And we showed how you can easily implement state management by storing simple properties in your control's ViewState dictionary.

In this chapter, we will examine complex properties ” that is, properties whose types do not have a simple string representation. These types include nonatomic value types, reference types other than String, and collection types. When you expose complex properties from your control, you have to do additional work to support declarative persistence and state management. We'll show how to implement those features by walking through examples of controls that expose complex properties. We'll begin by describing the pieces that enable declarative persistence and show how to implement them. We'll then look at state management and show how you can implement custom state management for a complex property. Finally, we'll examine collection properties and implement an ImageMap control that demonstrates custom types, state management, and collection properties. Custom state management for properties is a more advanced aspect of control authoring. If you do not need this functionality, feel free to skim the sections that describe custom state management.

The ImageMap control that we'll implement toward the end of this chapter provides a strongly typed abstraction over the HTML <map> element, an image which contains regions that are activated when a user clicks them. ASP.NET does not provide a built-in map control. The HTML <map> element is described in the HTML 4.0 specification at: http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.6.



Developing Microsoft ASP. NET Server Controls and Components
Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer)
ISBN: 0735615829
EAN: 2147483647
Year: 2005
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net