- Part 7
Creating ASP.NET Mobile Web Applications
- Topic 1
- Use device-specific rendering to display controls on a variety of devices.
- Use adaptive rendering to modify the appearance of Web server controls.
- Use the mobile Web controls to display content on a device.
To use device specific rendering you must set up filters in your web config or machine config that define what device capabilities you are looking to target. Then you can use DeviceSpecific Control in your code to specify which value to use. In the example taken from the resources, a mobile image control has different values for ImageUrl depending on the device:
<mobile:Image runat=server >
<Choice Filter="IsHtml" ImageURL="Logo.gif" />
<Choice Filter="IsWbmp" ImageURL="Logo.wbmp"/>
</mobile:Image> In the Web Config:
<filter name="IsHtml" compare="PreferredRenderingType" argument="html32" />
<filter name="IsWbmp" compare="PreferredImageMime" argument="image/vnd.wap.wbmp" />
The process of creating different markup and layout for different devices is known as adaptive rendering. In ASP.Net most controls have this capability built in so you can use all web controls and they will render correctly on any type of device.
The controls that ship with ASP.Net 2.0 and are mobile ready include Container Controls that include Form and Panel Controls, Standard Controls that include AdRotator, Calendar, Label, Textbox, TextView, Command, Image, PhoneCall, and Link Controls, and List Controls that include List, ObjectList, and SelectionList Control, and ValidationControls that include CompareValidator, CustomValidator, RangeValidator, RegularExpressioValidator, RequiredFieldValidator and ValidationSummary Controls and special controls like the DeviceSpecific Control mentioned earlier and a Stylesheet Control.
Other Resources & Links:
Device Specific Rendering
Mobile Magic: Device Specific Rendering – Device Specific Control
A Look at ASP.NET's Adaptive Rendering
Using ASP.Net Mobile Controls in the designer