The various types of
ASP.NET server controls, which can be broken down into four broad categories:
·
Intrinsic controls -- these controls
correspond to their HTML counterparts, or simulate one if none exists. Examples
include the Button, ListBox, and TextBox controls.
·
Data-centric controls -- controls used for
binding and displaying data from a data source, such as the DataGrid control.
·
Rich controls -- these controls have no
direct HTML counterparts. Rich controls, like the Calendar control, are made up
of multiple components, and the HTML generated will typically consist of
numerous HTML tags (as well as client-side script), to render the control in
the browser.
·
Validation controls -- like, for example,
the RequiredFieldValidator, which can be used to ensure proper data input
within a web form.
two additional types of
controls that you should be aware of:
·
HTML Server Controls
·
User Controls
HTML
server controls correspond directly to various HTML tags, and are defined
within the System.Web.UI.HtmlControls
namespace. These controls derive their functionality from the System.Web.UI.HtmlControls.HtmlControl
base class. Microsoft provides this suite of HTML server controls for a couple
of reasons:
·
Some web developers may prefer to work with
the HTML-style of control that they're used to
·
Developers can convert existing HTML tags
to HTML server controls fairly easily, and thus gain some server-side
programmatic access to the control
The following HTML tag
declaration is, believe it or not, a fully qualified HTML server control that
can be accessed programmatically on the server within your web form's code:
<INPUT id="MyHTMLTextBox" type="text"
name="MyHTMLTextBox"
runat="server">
What makes this a programmable HTML server control? Simply the reference
to runat="server. In this example, using runat="server" ensures that the .NET
Framework will convert the HTML tag into a corresponding HtmlInputText object (there is an HTML
server control object for every corresponding HTML tag). We also add id="MyHTMLTextBox", to provide a unique name
of the object so that we can reference it in our server-side coderunat="server">
No comments:
Post a Comment