Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] - نسخه متنی

Andy Wigley; Peter Roxburgh

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید






Chapter 9: Customizing with Property Overrides and Templates

In this chapter, you'll learn how to customize your applications for a particular client device and how to customize the Form and Panel controls using templates. You'll use property overrides to set control properties that apply to a specific subset of client devices. You'll use the template features of the Form and Panel controls to override the default rendering of these controls, which allows you to include device-specific markup in the content sent to the client. These features give you great flexibility in the way you present your mobile Web Forms controls on specific mobile devices.


Customization Overview


Property overrides and templates are both techniques for customizing your application for different mobile devices. You apply either of these customization techniques to a mobile control in an .aspx page using a section of server control syntax called a DeviceSpecific/Choice construct. This construct allows you to identify particular client devices or particular groups of client devices. For example, the following server control syntax is for a Label control, which has a DeviceSpecific/Choice construct which identifies HTML browsers:

    <mobile:Label id="Label1" runat="server"
Text="Default text">
<DeviceSpecific>
<Choice Filter="isHTML32"
Text="Text for selected devices" >
</Choice>
</DeviceSpecific>
</mobile:Label>

The Filter="isHTML32" attribute applies a Device Filter. This device filter is called isHTML32 and identifies client devices that have HTML 3.2 browsers. For those devices identified by Choice device filters, the contents of the <Choice>…</Choice> elements are applied, which might be a Property Override or a Template. In the example just shown, the <Choice> element applies a property override for the Text property of the Label.

We'll look at how you define device filters first in this chapter. Before we do that, let's take a high-level overview of Property Overrides and Templates to see how and when they would be used.


Property Overrides


By design, the Microsoft ASP.NET mobile controls allow you to develop applications for a broad range of mobile devices. These devices share the characteristics of being small, portable, and able to connect to the Internet. Despite their similarities, however, these devices can also differ substantially. For instance, color support, screen display size, input capabilities, and markup language support can differ widely among mobile clients. Applications you develop using the ASP.NET mobile controls operate on all supported mobile devices, and the properties you set on any mobile control apply to all those devices. However, you'll sometimes want to override the default rendering of your application on a particular device. A typical example is that you might show shorter strings on mobile devices that have smaller display areas and longer strings on other devices. Property Overrides is a technique that allows you to set properties of mobile controls to different values on different devices.


Templates


The Form, Panel, List, and ObjectList mobile controls are templated controls. Templates are the most powerful tool you have for customizing the appearance and/or content of your application. The Form and Panel controls allow you to define items such as a header or footer within the template. This content is then inserted into the rendered page and displayed at the top (the header) and the bottom (the footer) of each display page. In the case of the List and ObjectList controls, templates allow you to completely override the appearance of the control's content. (We focus on the Form and Panel controls in this chapter and examine List and ObjectList templates in Chapter 10.) The template can contain ASP.NET controls or literal text. The literal text is inserted into the rendered page sent to the client; this literal text you write could be the markup that the client browser understands. An example of the application of this technique is to use the Form control templates to inject HTML markup into the response sent to HTML clients which formats the page as an HTML table, taking advantage of all the inherent formatting flexibility of HTML.

/ 145