Name
WebControl
Synopsis
This class is the base class for all web controls. The WebControl
class derives much of its
basic functionality from System.Web.UI.Control
, including
functionality for data binding and using view state. The WebControl
class adds additional user-interface specific members for configuring the control’s appearance—including a
collection of CSS attributes
(Style
), color options
(BackColor
and ForeColor
), a shortcut key
(AccessKey
), and various
border style, font, and dimension properties. One interesting property that is
specific to web controls is CssClass
, which sets the
Cascading Style Sheet class applied to the control. This is rendered as the class
attribute in HTML (for example, <input type=text class="class1" style="ForeColor:red">
). Some properties, such as AccessKey
, may not be
supported on down-level browsers.
All methods and the TagName
, TagKey
, Attributes
, and Style
properties are provided
for developers to use or override in custom web controls. If you want to create a
server control that renders user interface (HTML), you should extend one of the web
control classes or inherit directly from WebControl
rather than the more basic System.Web.UI.Control
class. You should override the RenderContents()
method,
which provides a System.Web.UI.HtmlTextWriter
for generating
output. You do not need to manually output style attributes (or the basic HTML tag,
if you have supplied it to the base WebControl
constructor), as the WebControl
class will handle these ...
Get ASP.NET in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.