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 ...

Get Programming ASP.NET 3.5, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.