HTML
server controls offer a variety of features, which include:
·
Programmatic Object Model --
you can access HTML server controls programmatically on the server using all
the familiar object oriented techniques. Each HTML server control is an object
and, as such, you can access its various properties and get/set them
programmatically.
·
Event Processing
-- HTML server controls provide a mechanism to write event handlers in much the
same way you would for a client-based form. The only difference is that the
event is handled in the server code.
·
Automatic Value Caching
-- when form data is posted to the server, the values that the user entered
into the HTML server controls are automatically maintained when the page is
sent back to the browser.
·
Data Binding
-- it's possible to bind data to one or more properties of an HTML server
control.
·
Custom Attributes
-- You can add any attributes you need to an HTML server control. The .NET
Framework will render them to the client browser without any changes. This
enables you to add browser-specific attributes to your controls.
·
Validation
-- you can actually assign an ASP.NET validation control to do the work of
validating an HTML server control. Validation controls are covered in detail
later in this chapter.
One reason you might
consider using HTML server controls in your own web form pages, is to leverage
an existing HTML page's HTML tag or code base. For example, let's say you have
an existing HMTL page that you would rather not re-write from scratch, but
still would like to write some server-side code to access various properties of
the various controls on the page. Converting an existing HTML page's controls
to HTML server controls is simple: you just add the runat="server"
attribute within the tag declaration of the HTML control. You might also need
to add an id="MyControl"
reference, where "MyControl" is your unique naming identifier for
this object so that you can reference the object in your server-side code.
No comments:
Post a Comment