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

68

Saturday Morning

So, when choosing a language, pick the language with which you are most comfortable. We are guessing that VB.NET and C# will gain the widest acceptance, so, if you’re looking for support, those might be the best choices.

REVIEW

ASP.NET provides an event-oriented programming model. When an ASP.NET page is loaded, a structured series of events are fired in a set order. You can write code that responds to these events rather than interspersing it with HTML, as you had to do if you programmed in ASP.

ASP.NET pages can also be managed and controlled through the use of page directives, which specify optional settings to be used by the page compiler. One of these page directives is Import, which provides ASP.NET page access to .NET services.

QUIZ YOURSELF

1.What is a page directive? (See “Page Directives.”)

2.Which namespaces are used for data access? (See “Namespaces.”)

3.What event is fired every time a page is loaded? (See “ASP.NET Events.”)

S E S S I O N

8

Using HTML Controls

Session Checklist

Understanding the usefulness of HTML controls

Learning to utilize server-side event handling

Implementing HTML controls to maintain state

In today’s distributed computing environment, one of the biggest issues developers face is writing code that can effectively run on numerous browser types and versions, and maintaining state between server requests. Writing an Internet application can be very

tedious when attempting to write code that can run simultaneously on different browsers, operating systems, and other devices. If you’ve ever tried writing an application that takes full advantage of the feature set of Internet Explorer 5.0 while still being compatible with Netscape 3.0, you know what we’re talking about.

Many developers take the “lowest-common-denominator” approach to solving this problem. This means they write applications that utilize the feature set of older browser versions (for example, Netscape 3.0) and have all other clients, regardless of capability, execute the same code. Naturally, this approach has drawbacks of its own. For example, in this particular case, more round-trips to the server are required, resulting in performance degradation.

Note

Using newer browser versions, state maintenance is less of a headache than with older browsers. For example, with IE 5 and DHTML, HTML form validation can be done on the fly by the client browser so fewer round trips to the server are required than when the same application is run on, for example, Netscape 3.0. All of these extra trips to the server dramatically increase server load and decrease application performance.

Yet another solution to the multiple browsers problem is writing different code for different browsers. This is generally accomplished by using a third-party component (or writing your own) that determines the type of client browser that is making the request and executing the server-side code written for the requesting browser type. This too is a valid approach to