O'Reilly logo

Special Edition Using® Microsoft® ASP.NET by Richard Leinecker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Properties and Methods to Your Control

Properties, by definition, are characteristics that you can modify at design time. Font color is a good example of a text property. Methods, by definition, are self-contained blocks of code referenced by a name. You can see an example of such a code block in the code in Listing 13.3, in the form of Output.Write(), where Write() is a method of the Output class.

The example in Listing 13.4 demonstrates how to write a control that exposes three custom properties (of type string, integer, and enum) and then uses them to render some custom content based on how the properties are set. The syntax to add a property is as follows:

Listing 13.3. A Class with a Single Property
 public string SomeProperty { ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required