Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ASP .NET Database Programming Weekend Crash Course - J. Butler, T. Caudill.pdf
Скачиваний:
31
Добавлен:
24.05.2014
Размер:
3.32 Mб
Скачать

Session 8—Using HTML Controls

77

REVIEW

HTML controls are server-side ASP.NET controls that render browser-specific HTML. HTML controls reduce the time required to develop HTML that will correctly render on different browsers; and they can be used to maintain state between server requests. HTML controls also allow us, as developers, to capture client-side events and process them on the server.

QUIZ YOURSELF

1.What attribute/value pair must be included in an HTML control declaration? (See “Using HTML controls.”)

2.What is the purpose of the hidden VIEWSTATE form field? (See “How HTML controls work.”)

3.What is the advantage of using ASP.NET server-side event processing over the more traditional client-side event processing? (See “HTML Control Events.”)

S E S S I O N

9

Using Web Controls

Session Checklist

Understanding the usefulness of ASP.NET Web controls

Learning how to implement Web controls

In the previous session, “Using HTML Controls,” we discussed how to utilize HTML controls to maintain state between server requests. If you recall, there are two major problems that Web developers commonly face: (1) state maintenance and (2) browser

compatibility. HTML controls effectively manage the state maintenance issue, but not

the browser compatibility issue. That is where Web controls come in. Web controls are very similar to HTML controls but provide a higher degree of control and programmability.

Web controls do not map one-to-one with HTML controls. Instead, Web controls are abstract controls in which the actual HTML rendered by the control might be quite different from the model that you program against. Web controls include traditional form controls such as buttons and text boxes, as well as complex controls such as tables. They also include controls that provide commonly used functionality, for example displaying data in a grid or choosing dates. Many Web controls can also be bound to a data source such as an ADO.NET DataSet.

Web controls offer all the same advantages as HTML controls plus the following:

Type-safe programming capabilities. Web controls offer a rich programming model that provides type-safe programming capabilities because you, as a developer, can be certain of the type of data a variable contains. Type-safe programming means that a variable is declared as a specific data type (for example integer or string) and can only be assigned values of that type. Type-safe programs are, in most instances, far easier to debug and result in fewer run-time errors.

Automatic browser detection. The controls can detect capabilities and create appropriate output for both basic and rich (HTML 4.0) browsers.

Custom templates. For some Web controls, you can define your own look and feel using templates.