O'Reilly logo

Programming ASP.NET 3.5, 4th Edition by Jesse Liberty, Dan Hurwitz, Dan Maharry

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, but as AJAX controls prove, the judicious addition of script to be run on the browser can be a distinct advantage. It can speed up a page’s execution by controlling how it communicates with the server and it can provide a much-improved user experience as well.

It may strike you as odd, though, that despite this hoo-ha about JavaScript, this book won’t look at writing any JavaScript (or any VBScript, for that matter) directly onto the page, except in this section. That’s not to say the authors of this book dismiss it, but rather that it isn’t core to the topic of writing ASP.NET pages and you simply don’t need to know what JavaScript is being generated by the AJAX controls used here. It just works.

There are exceptions to the rule, of course: 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 a script to the browser so that invalid data is caught and flagged to the user without requiring a round trip to the server. 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, you can call client-side code from any ASP.NET server control. In addition, the ASP.NET Button server control has a property, OnClientClick, which lets you specify client-side script to execute when the button is clicked.

Conventional ...

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