Programming Microsoft ASP.NET 4 - Dino Esposito [143]
// Views is an auto-postback drop-down list
Tables.ActiveViewIndex = AvailableViews.SelectedIndex;
}
The combination of View and MultiView controls lends itself very well to implementing wizards. In fact, the new ASP.NET Wizard control uses a MultiView control internally. We’ll cover the Wizard control in Chapter 8.
Figure 6-6. A multiview control in action.
ASP.NET Miscellaneous Controls and the AJAX Revolution
This book is designed to be a reference for ASP.NET developers. The book is designed to stay mostly idle on the desk and be used when you get in trouble and can’t move further without a clear and deep understanding of a given ASP.NET feature. So this book puts more effort into explaining the underpinnings and architecture of ASP.NET components rather than trying to solve common problems by illustrating relatively common techniques. On the other hand, with Google you can navigate through zillions of blogs and can address your technical urgency effectively in a relatively quick time. With specialized sites such as StackOverflow (http://www.stackoverflow.com), you can likely just type in your question and find exactly the answer you were looking for.
So how does this relate to miscellaneous ASP.NET controls?
While planning this ASP.NET 4 programming book, I debated for long time whether to include this chapter. Why? Because I was supposed to discuss relevant things about most of the Web and HTML controls. But most of these controls are losing importance in modern Web applications.
The Calendar control you find in ASP.NET is fairly useless at this stage of Web development. If you need to let the user pick a date, you use a script-based, date-picker extension for a text box. If you need a real calendar to lock dates, either you resort to richer script-based solutions or you derive your own calendar from the base one. Most of the same things can be said for the View and MultiView controls. The underlying idea they represent is more valid than ever, but the postback-based implementation is not. You want to use AJAX scripts to switch between views and tabs. Wrapping a MultiView control in an updatable panel can do the trick of refreshing views with limited impact on the user. But the direction seems to be another—using script libraries such as jQuery UI. And such libraries have nothing to do with controls like MultiView.
Finally, let’s discuss the AdRotator control. The importance of such a component is a no-brainer. Everybody wants to have ads on their site. But ads must not be bound to postbacks in AJAX-intensive sites. The AdRotator control can be revamped with partial rendering and updatable panels, but more often than not you resort to richer forms of display based on Silverlight or Flash.
In summary, more than five years after the “official discovery” of the AJAX paradigm, we realize that Web programming is changing, and so is ASP.NET. ASP.NET Web Forms is still valid and can still help in writing a lot of successful code. But some of its core components and ideas are becoming obsolete every day. Be aware of this when you pick up a book or, more importantly, when you write your code. ASP.NET MVC is a new paradigm that seems closer to the current needs of developers. For more information, check out my book Programming ASP.NET MVC (Microsoft Press, 2010).
Summary
In ASP.NET pages, server controls are vital components and transform the programming model of ASP.NET from a mere factory of HTML strings to a more modern and effective component-based model. ASP.NET features a long list of control classes. Looking at the namespaces involved, you should conclude that only two families of controls exist: HTML and Web controls. Controls in the former group simply mirror the set of elements in the HTML syntax. Each constituent control has as many properties as there are attributes in the corresponding HTML tag. Names and behavior have been kept as faithful to the originals as possible. The ultimate goal of the designers of HTML controls is to make the transition from ASP to ASP.NET as seamless as possible