Developing Microsoft ASP.NET server controls and components

Author : Nikhil Kothari & Vandana Datye
Microsoft Press
ISBN-0-7356-1582-9
The ASP.NET framework is great library of components to build web based
applications. It contains a large collection of controls to populate web
pages and a components to build non visual apps like web services. This book
explains how to extend the framework with your own components. But also when you
are quite satisfied with the existing classes this is a great book to understand
how ASP.NET works.
The book is divided in six parts
The first part provides an overview of the fundamentals. It very briefly
explains the basics of .NET and HTTP request processing after which the page
programming model of ASP.NET is explored in more depth. An ASP.NET web
application consist of aspx pages, these have a layout which you edit visually
in a tool as Visual Studio.NET. The server side controls provide the actual
functionality. These controls and other components are programmed using
properties, methods and events.
- II Server controls - First steps
There are actually two kinds of controls. User controls are a way to re-use
(parts of) a web page on other web pages. Beside the controls on the user
control you can add additional properties and methods on the user control as a
whole. Custom controls are controls like a text-box, label or datagrid. This
part of the book explains the basics of creating user controls and custom
controls. To finish it compares the two types of control and explains when to
use which.
- III Server controls - Nuts and Bolts
Over the half of the book is taken up by this part which handles all the
details how a custom control works and is built. In the first chapters the
architecture of ASP.NET server controls is explained. You will read how the
viewstate is used to maintain the state of a control over the roundtrips between
client and web server. You will read how a server side controls emits pure HTML
code to the result page being sent to the client. You will read how a postback
is processed in a webpage. The schema on this (page 175) with the explaining
text can also be found in the docs of the framework but IMHO it should be
printed in boldface on the cover of every ASP.NET manual. All kinds of aspects
of the controls come by : styles, validating, client side scripts, data-bindings
and localization. The text describes not only how things work but also how to
alter the workings and add your own functionality. Even if you don't have any
plans for creating custom controls the information is very useful as it explains
a lot on using and programming the existing controls. But when reading you will
discover that creating your own controls is no longer the rocket science it used
to be. Adding design time support has also become easy, it is mainly a matter of
decorating your control and its properties with
attributes.
The term component has a lot of meanings. It can stand for a class, an object
of the System.ComponentModel.Component class or any "programmable thing" at all.
Even in this book the term is sometimes used in a slightly confusing manner. In
this part of the book the term component stands for web services and HTTP
handlers. The chapter on web services provides an introduction on the .NET
implementation of web services and focuses on using them a in a custom web
control. An HTTP handler is a class which handles web requests with a given
extension. All request with an aspx extensions are handled by the
PageHandlerFactory which will treat the request as a request for an asp.net
webform. All request with an asmx extensions are treated as a request for a web
service. You can define your own extension and create your own code to handle
the requests. The chapter on HTTPhandlers describes how to configure your web
server and how to create the handling code without needing a deep knowledge of
the IIS web server.
- V Server Control Case Studies
To get an idea of the many possibilities explained in the book two real-life
control cases are discussed in detail. One chapter describes the full
implementation of a listview control which is similar to the datalist control in
the .NET framework. A major problem with server side controls is that all code
is executed on the server which can happen only once on a roundtrip. To get a
more responsive control you need some client side script which executes in the
browser. The second case study discusses a D(ynamic)HTML server side control
which emits client side script. Not every browser has the same support for
scripting, one of the nice things of a server side control is that it can
determine the browsers capabilities and emit the right script to match these
capabilities. This way the best of all worlds is brought together.
The appendices complete the book. One chapter provides an overview of all the
attributes you can use in the implementation of a custom control. Another
chapter an overview of the properties and methods of the base classes used when
creating custom controls. The final chapter spends a couple of pages on
Web-Matrix, a new free Microsoft web development tool.
Conclusion
I would recommend this book to everybody who does serious development of
asp.net web pages. Even if you don't plan to develop your own controls this book
does give you a great insight in asp.net webforms. Nikhil and Vandana both write
in a beautiful style which is very comfortable to read and easy to understand.
The book brings the rocket science, which asp.net really is, back to earth.
|