O'Reilly logo

Programming ASP.NET, 3rd Edition by Dan Hurwitz, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Client-Side Processing

Server-side processing is at the heart of ASP.NET. However, this approach does have some shortcomings. The main problem is that a postback to the server is required before any processing can occur. Even for intranet applications connected to the server with a high-speed local network connection, this introduces a noticeable delay often unacceptable to the user experience. For Internet applications, even those connected via high-speed broadband, the delays can seem interminable.

Client-side processing can greatly enhance the user experience, providing nearly instantaneous response to user actions. This is accomplished using scripting languages such as JavaScript or VBScript.

Some ASP.NET server controls use client-side scripting to provide responses to user actions without posting back to the server. For example, validation controls typically download script to the browser so invalid data are caught and flagged to the user without requiring a round trip to the server. However, in these cases, this client-side script is provided by ASP.NET and you, the developer, do not have to write or manage that script.

As you will see, calling client-side code from any ASP.NET server control is possible. In addition, the ASP.NET Button server control has a property, OnClientClick, that lets you specify client-side script to execute when the button is clicked.

Conventional and server HTML controls expose a number of events that can execute script when they are raised. This script ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required