Introducing the Microsoft Mobile Internet Toolkit

IOTA^_^    

ASP.NET Developer's JumpStart
By Paul D. Sheriff, Ken Getz
Table of Contents
Chapter 25.  Creating Mobile Web Applications


The Microsoft Mobile Internet Toolkit (MMIT) adds features to ASP.NET that support handheld and mobile devices. Using this toolkit, you can create a single application that targets multiple devices and standards. In general, the MMIT is an SDK that takes advantage of the features of ASP.NET as well as integrates tightly with the Visual Studio .NET development environment.

The MMIT provides useful features for Web developers. In specific, the MMIT does the following:

  • Creates write-once mobile Web pages. Rather than requiring you to rewrite your pages for multiple devices, the MMIT allows you to create the pages once, and then the toolkit renders the pages according to the information passed to ASP.NET from the browser, in the HTTP request header information.

  • Supports multiple markup languages. So that you don't have to create separate pages for HTML, WML, cHTML, and so on, the MMIT handles this detail as it renders the pages.

  • Supports a variety of devices. Mobile browsers come in all sorts of devices, from Pocket PCs to pagers to e-mail devices. The MMIT handles them all, and it can be expanded by adding more device-configuration information.

  • Integrates with Visual Studio .NET. The MMIT adds a new project type (Mobile Web Application) and page type (Mobile Web Page) to Visual Studio .NET. You use the tools you're accustomed to using to create Web pages that can be browsed from virtually any browser.

In this chapter, you'll use the Microsoft Mobile Internet Toolkit to create a simple page and then test it using one or more mobile device emulators. You'll learn about the controls provided by the MMIT and how to write code binding data to these controls.

Testing Mobile Pages

Unless you like collecting gadgets or have unlimited funds, you probably won't want to buy a device containing each different possible browser just to test your site. To make this task more reasonable, developers of each of the popular mobile browsers have released simulators that you can run on your development machine. You'll want to download or purchase simulators for all your target platforms. We tried four different simulators, as listed here:

  • OpenWave's UP.SDK simulator for the Unwired Planet (UP) browser (http://developer.phone.com)

  • Nokia's Mobile Internet Toolkit for its mobile phones (http://forum.nokia.com)

  • Microsoft Mobile Explorer for phones using Microsoft's software (http://www.microsoft.com/mobile/phones/mme/mmemulator.asp)

  • Microsoft's Pocket PC emulator for its Pocket IE (www.microsoft.com/mobile/developer)

Note that many of the simulators support "skins" (that is, graphics that make the simulator look more like a specific device) and may provide multiple skins.

TIP

If you're going to use the Pocket PC emulator, you'll need to also download a patch from Microsoft's Web site that allows JScript to work in the emulator. For more information, visit support.microsoft.com and look for Knowledge Base article Q296904.


Handling Mobile Requests

When a device makes a request against a Web site, that HTTP request makes its way through the Internet to your site. IIS renders a response, sent back to the browser, for display there. Cell phones, on the other hand, don't "understand" HTTP. Instead, must current cell phones use the Wireless Application Protocol (WAP) as their means of transmission. To hit current Web sites, cell phones pass their requests through a gateway (normally provided by the wireless ISP) that converts the WAP requests, using WML (Wireless Markup Language), to HTML and HTTP and then sends the requests on to the Web server. The Web server gets the requests, investigates the request header information to determine the source of the request (that is, the exact type of browser and its capabilities) and then generates a response. The response goes back to the browser; however, for cell phones, the response passes through the gateway again, which converts the HTML/HTTP information into WML/WAP.

The MMIT does the work of determining the capabilities of the requesting browser and renders the output of the controls you've placed on your pages so that it can be viewed on the host browser. If the browser doesn't support many lines, for example, the MMIT may render Command controls (seen as buttons on a standard browser) using the softkey on the device (the labeled button at the bottom of the screen with a software-supplied label).

Controls Supplied by MMIT

In its original release, the MMIT supplies controls that can be broken down into seven basic categories:

  • Container controls. The Form and Panel controls contain other controls. The Form control is the basis for breaking up pages into smaller chunks. The Panel control allows you to group controls so that you can treat them all as a programmable entity (to hide and show the entire group, for example).

  • Transfer controls. The PhoneCall control allows you to initiate a voice call, if the device supports it. The Command control acts much like a Button control in ASP.NET pages, except that the Command control may be displayed as either a button on "large" browsers or as a softkey on compact browsers. The Link control acts as a hyperlink, allowing you to navigate from one form to another form or page, without having to write any code.

  • Text display controls. The TextBox and Label controls work much like the ASP.NET equivalents. The TextView control works like a Label control, but it also allows you to display formatted and paginated text containing a limited subset of HTML attribute tags.

  • List and selection controls. The List control allows you to display a list of items, and you can choose plain, bulleted, or numbered lists. You can react to the ItemCommand event when a user selects an item. The SelectionList control also displays a list of items, but this control also supports five different views (DropDown, ListBox, Radio, MultiSelectListBox, and CheckBox) and doesn't raise an event when you select an item. You'll need some other control (such as a Command control) to take an action after you've selected one or more items. The ObjectList control can be bound to a data source (that's the only way to supply it with data) and provides two views of the data a table view and a details view. You'll investigate this complex control, in depth, later in the chapter.

  • Validation controls. Provides much the same behavior as the parallel ASP.NET validation controls.

  • Image display controls. The AdRotator and Image controls work much like their ASP.NET parallels.

  • Miscellaneous controls. The DeviceSpecific control allows you to add property settings and behaviors that are specific to a single device, given characteristics that you specify. The MMIT supplies a number of predefined filters and specifications for devices. You can add your own, as well. The StyleSheet control allows you to bypass the otherwise missing support for Cascading Style Sheets in the MMIT. You can create named styles and associate them with controls' properties. The Calendar control allows you to request date information from users.

NOTE

The MMIT includes three predefined styles: error, subcommand, and title. You apply these styles to a control by setting the StyleReference property.


WARNING

Although the Calendar control's output looks great on "large" browsers, there's no room for a graphical calendar display on small browsers, and the whole interface works differently there. Make sure you investigate this before using the Calendar control on one of your pages.



    IOTA^_^    
    Top


    ASP. NET Developer's JumpStart
    ASP.NET Developers JumpStart
    ISBN: 0672323575
    EAN: 2147483647
    Year: 2002
    Pages: 234

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net