Creating CSS Friendly Websites with ASP.NET 2.0

Posted by: 4GuysFromRolla.com Headlines, on 29 Nov 2006 | View original | Bookmarked: 0 time(s)

One of the features of ASP.NET 1.0 was its adaptive rendering capabilities that allowed for the markup rendered by an ASP.NET web page to be appropriate for the visiting browser. In short, when an ASP.NET page is visited its Web controls are rendered into markup that is sent down to the browser and displayed. The markup generated by the Web controls, however, depends upon the browser being used to visit the page. When visited by an "uplevel browser" ASP.NET Web controls render HTML 4.0-compliant markup; for "downlevel" browsers, the Web controls render HTML 3.2-compliant markup. In ASP.NET 1.x, browsers were labeled as "uplevel" or "downlevel" via the <browserCaps> element in machine.config or web.config (one downside of ASP.NET 1.x was that, by default, only IE 4.0 and up was marked as "uplevel" meaning modern browsers like FireFox and Opera were flagged as downlevel). See A Look at ASP.NET's Adaptive Rendering for more information on ASP.NET 1.x's adaptive rendering functionality.

ASP.NET 2.0 provides the same adaptive rendering as ASP.NET 1.x, although a browser's capabilities are determined by Browser Definition Files rather than a <browserCaps> element. (<browserCaps> support still exists in ASP.NET 2.0 for backwards compatibility, but has been deprecated and its use should therefore be avoided.) In addition to adaptive rendering, ASP.NET 2.0's rendering framework also can be configured using control adapters. A control adapter is an optional class that, if present and properly configured, is used to render the Web control instead of using the control's default rendering logic. In short, using control adapters you can take the core functionality of a Web control, but completely customize the markup emitted. This is useful if you want to modify the default rendering for all browsers or if there are particular user agents - certain cell phones or portable devices, perhaps - for which you need to provide a customized rendering.

A good example of the power of ASP.NET 2.0's control adapters can be seen with the ASP.NET 2.0 CSS Friendly Control Adapters. This set of free control adapters, released by Microsoft, provide a set of control adapters that render a variety of built-in ASP.NET controls using preferred CSS techniques. For example, by default the Menu Web control renders as an HTML <table>; with the control adapters, however, the Menu is rendered as an unordered list using CSS positioning to appropriately display the menu. Moreover, the CSS control adapters ignore any control-level style settings that would get rendered as inline style elements in the rendered markup and instead require that style information be separated out and specified via CSS classes.

In addition to a control adapter for the Menu control, the CSS Friendly Control Adapters include adapters for the TreeView, GridView, DataList, DetailsView, Login, CreateUserWizard, and a variety of other controls. In this article we'll look at how to get started with the CSS Friendly Control Adapters and how they can clean up and improve the markup of your website. Read on to learn more!
Read More >

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: ASP.NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1916 | Hits: 98

Similar Posts

  • JavaScript >> Get Any CSS Property Value of an Object using $style more
  • $style - Get Any CSS Property Value of an Object more
  • Next Version of DNNMenu more
  • CSS Tutorial Designing Without Tables and Not Lose Resizable, Custom Borders more
  • ASP.NET Podcast Show #14 - Editable Datagrid more
  • TableLess CSS Design more
  • TableLess CSS Design more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD