Chapter 7. Taking control of markup

 

This chapter covers

  • Adaptive rendering
  • How to build control adapters
  • Browser capabilities providers in ASP.NET 4.0

Although ASP.NET MVC is the ideal choice when you want to precisely control the markup generated by your pages, you can use an ASP.NET Web Form to achieve similar results. Plus, the truth is that you probably have investments in Web Form-based applications. You can’t rewrite them because that will cost you money—and time.

As you learned in chapter 4, ASP.NET 4.0 is committed to generating better markup and providing better adherence to web standards, so in most situations you won’t need to modify the standard output. At the risk of repeating ourselves, remember that ASP.NET is built with extensibility in mind, so if you need to adapt a control rendering to a specific need, you can leverage one of the most underestimated features—and the hidden gem—of ASP.NET: adaptive rendering.

Adaptive rendering isn’t entirely new to ASP.NET 4.0, but its features are enhanced in this version, with a new pluggable provider model added to the browser capabilities engine. By writing a new provider, you can alter the rendering process without changing your code.

Adaptive controls, on the same hand, can be used to modify the output generated by a single control, to adapt it to different browsers, or simply to provide a different output without needing to change the markup already in place.

7.1. ASP.NET adaptive rendering

7.2. ASP.NET 4.0 browser capabilities

7.3. Summary