Programming Microsoft ASP.NET 4 - Dino Esposito [125]
This code in version 3.5 will produce the following markup:
| onkeyup="Menu_Key(this)" id="NavigationMenun0"> | onkeyup="Menu_Key(this)" id="NavigationMenun1"> |
As you can see, it is table-based output where most inline style information has been stripped off thanks to the IncludeStyleBlock property being set to false. Here’s the markup you get according to the 4.0 rendering procedure:
The visual output is not the same as shown in Figure 6-1. To achieve a given visual result with the 3.5 rendering approach, you must add style information to the control declaration; in 4.0, you just edit at the CSS level.
Figure 6-1. Menu rendering according to version 3.5 (left) and 4.0 (right).
In ASP.NET 4, a bunch of other controls feature additional properties to let developers gain more control over the structure of the returned markup. For example, some view controls (for example, FormView and Login) stop rendering inside of a table if you set the property RenderOuterTable to false. Likewise, validation controls and the Image control stop rendering inline style blocks. Finally, list controls such as the CheckBoxList control have additional options for the repeat layout to emit plain ordered or unordered HTML lists.
Browser-Sensitive Rendering
In ASP.NET 4, as well as in older versions, you can declaratively assign a browser-specific value to a given control property. Here’s a quick example:
mozilla:Text="Firefox Button" /> The Text property of the button will contain “IE button” if the page is viewed through Internet Explorer and “Firefox button” if the page goes through Firefox. If another browser is used, the value of the unprefixed Text attribute is used. All properties you can insert in a tag declaration can be flagged with a browser ID. Each supported browser has a unique ID. As in the preceding code, ie is for Internet Explorer and mozilla is for Firefox. Unique IDs exist for various versions of Netscape browsers and mobile devices. Browser IDs are interspersed in .browser files, which you can find at this path: %windows%\Microsoft.NET\Framework\[version]\CONFIG\Browsers Themeable Controls Server controls can dynamically accept or deny theming through a Boolean property named EnableTheming, which is set to true by default. As a
In ASP.NET jargon, a theme is a named collection of property settings that can be applied to controls to make them look consistent across pages. You can apply theme settings to an entire Web site, to a page and its controls, or to an individual control. A theme is identified by name and consists of CSS files, images, and control skins. A control skin is a text file that contains predefined values for some control properties. Applied together, these settings contribute to change the look and feel of the control and give the whole site a consistent (and, you hope, appealing) user interface. In addition, because themes are a sort of monolithic attribute, you can easily export that look from one application to the next. With themes enabled, if the developer adds, say, a DataGrid control to a page, the control is rendered with the default appearance defined in the currently selected theme.