Odds, Ends, and the WebControl Base Class

Odds, Ends, and the WebControl Base Class

All Web controls implement a long list of properties that enable them to be customized in a variety of ways. Some of those properties are defined in the control classes themselves; others are inherited from the WebControl base class. For example, all Web controls have properties named Width and Height because both of these properties are members of WebControl.

Not all WebControl properties are as ordinary as Width and Height. Take, for example, WebControl s CssClass property. I m frequently asked whether Web controls support cascading style sheets (CSS). The answer? Yes they do, thanks to the CssClass property that they inherit from WebControl. The following example defines a CSS class named Input and uses it to modify a TextBox control to display text in red 10-point Verdana type:

<html> <head> <style> .Input { font: 10pt verdana; color: red; } </style> </head> <body> <form runat="server"> <asp:TextBox Css RunAt="server" /> </form> </body> </html>

ToolTip is another property that Web controls inherit from WebControl. Want to display a tooltip window when the cursor hovers over a control? Then include a ToolTip attribute in the control tag, like this:

<asp:TextBox ToolTip="Type your name here" RunAt="server" />

There s virtually no end to the customizations you can perform when you have a firm grasp of all the properties and events that ASP.NET s Web controls expose. And when the built-in Web controls don t do what you want, you can always build controls of your own which is precisely what the next two chapters are all about.



Programming Microsoft  .NET
Applied MicrosoftNET Framework Programming in Microsoft Visual BasicNET
ISBN: B000MUD834
EAN: N/A
Year: 2002
Pages: 101

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