Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Building Microsoft ASP.NET Application for mobile Devices
Nội dung xem thử
Mô tả chi tiết
Building Microsoft ASP.NET Applications for Mobile
Devices, Second Edition
by Andy Wigley and Peter Roxburgh ISBN:073561914X
Microsoft Press © 2003 (694 pages)
This book shows programmers how to use the Microsoft .NET
Framework, ASP.NET, and Microsoft Visual Studio .NET 2003
to create powerful, next generation applications that are
available anywhere--on phones, Pocket PCs, and other mobile
devices.
Companion Web Site
Table of Contents
Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition
Introduction
Chapter 1 - Introducing Microsoft ASP.NET for the Mobile Web
Chapter 2 - Getting Started
Chapter 3 - Programming ASP.NET Mobile Web Forms
Chapter 4 - Programming the Standard Controls
Chapter 5 - Special-Purpose Controls and Validation Controls
Chapter 6 - Programming the List Controls
Chapter 7 - Using the Downloadable Controls
Chapter 8 - Programming Styles and Style Sheets
Chapter 9 - Customizing with Property Overrides and Templates
Chapter 10 - Advanced List Control Programming
Chapter 11 - Accessing Data
Chapter 12 - State Management
Chapter 13 - Enhancing Application Performance
Chapter 14 - Multilingual and Multicultural Web Applications
Chapter 15 - XML Web Services
Chapter 16 - Debugging, Testing with Emulators, and Handling Run-Time Errors
Chapter 17 - Packaging and Configuration
Chapter 18 - ASP.NET Application Security
Chapter 19 - Supporting New Clients
Chapter 20 - Building a Reusable User Interface as User Controls
Chapter 21 - Creating Custom Controls by Inheritance and Composition
Chapter 22 - Programming Device Adapters and Building Controls from Scratch
Index
List of Figures
List of Tables
List of Listings
List of Sidebars
Building Microsoft ASP.NET Applications for Mobile
Devices, Second Edition
by Andy Wigley and Peter Roxburgh ISBN:073561914X
Microsoft Press © 2003 (694 pages)
This book shows programmers how to use the Microsoft .NET
Framework, ASP.NET, and Microsoft Visual Studio .NET 2003
to create powerful, next generation applications that are
available anywhere--on phones, Pocket PCs, and other mobile
devices.
Companion Web Site
Table of Contents
Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition
Introduction
Chapter 1 - Introducing Microsoft ASP.NET for the Mobile Web
Chapter 2 - Getting Started
Chapter 3 - Programming ASP.NET Mobile Web Forms
Chapter 4 - Programming the Standard Controls
Chapter 5 - Special-Purpose Controls and Validation Controls
Chapter 6 - Programming the List Controls
Chapter 7 - Using the Downloadable Controls
Chapter 8 - Programming Styles and Style Sheets
Chapter 9 - Customizing with Property Overrides and Templates
Chapter 10 - Advanced List Control Programming
Chapter 11 - Accessing Data
Chapter 12 - State Management
Chapter 13 - Enhancing Application Performance
Chapter 14 - Multilingual and Multicultural Web Applications
Chapter 15 - XML Web Services
Chapter 16 - Debugging, Testing with Emulators, and Handling Run-Time Errors
Chapter 17 - Packaging and Configuration
Chapter 18 - ASP.NET Application Security
Chapter 19 - Supporting New Clients
Chapter 20 - Building a Reusable User Interface as User Controls
Chapter 21 - Creating Custom Controls by Inheritance and Composition
Chapter 22 - Programming Device Adapters and Building Controls from Scratch
Index
List of Figures
List of Tables
List of Listings
List of Sidebars
Back Cover
Extend your programming expertise across the widest range of mobile devices with this incisive guide to Microsoft
ASP.NET mobile controls. Now integrated into Microsoft Visual Studio .NET 2003, ASP.NET mobile controls enable you
to build applications that render intelligently on different devices—regardless of markup language, browser, or form
factor. The authors expertly guide you through the mobile Web application development process, explaining how to
fully exploit Visual Studio .NET and the Microsoft .NET Framework 1.1 for rapid and more flexible development.
Discover how to create innovative, intuitive solutions—instead of wrestling with interoperability issues.
Learn how to:
Build mobile Web Forms pages with device-independent properties, methods, and events
Use “code-behind” techniques to separate programming logic from the UI
Employ the standard controls or download new custom controls
Build controls from scratch and program device adapters
Customize applications for specific devices with templates
Access data using Microsoft ADO.NET and the Visual Database Tools
Know when to use application vs. session state
Apply best practices for using XML Web services in mobile applications
Help secure applications with ASP.NET authentication services
Develop multilingual and multicultural applications
Debug code, trap runtime errors, and use software emulators to test applications
Configure, package, and deploy applications
About the Authors
As a principal technologist at Content Master Ltd., a technical-authoring company based in the United Kingdom, Andy
Wigley focuses on the use of .NET in mobility applications. A software engineer for nearly 20 years, Andy has worked
on a diverse range of projects, including developing—along with the coauthor Peter Roxburgh—the first payments
service for Wireless Access Protocol (WAP) clients in the U.K. Peter, a technology specialist at Content Master, holds an
honors degree in business. He has contributed numerous articles on cutting-edge mobile technologies to professional
journals and Web sites.
Building Microsoft ASP.NET Applications for Mobile
Devices, Second Edition
Andy Wigley
Peter Roxburgh
PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399
Copyright © 2003 by Microsoft Corporation
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by
any means without the written permission of the publisher.
Library of Congress Cataloging-in-Publication Data pending.
1 2 3 4 5 6 7 8 9 QWE 8 7 6 5 4 3
Distributed in Canada by H.B. Fenn and Company Ltd.
A CIP catalogue record for this book is available from the British Library.
Microsoft Press books are available through booksellers and distributors worldwide. For further information
about international editions, contact your local Microsoft Corporation office or contact Microsoft Press
International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send
comments to mspinput@microsoft.com.
FrontPage, JScript, Microsoft, Microsoft Press, Mobile Explorer, MSN, Visual Basic, Visual C++, Visual C#,
Visual J#, Visual Studio, Windows, and Windows NT are either registered trademarks or trademarks of
Microsoft Corporation in the United States and/or other countries. Other product and company names
mentioned herein may be the trademarks of their respective owners.
The example companies, organizations, products, domain names, e-mail addresses, logos, people, places,
and events depicted herein are fictitious. No association with any real company, organization, product,
domain name, e-mail address, logo, person, place, or event is intended or should be inferred.
Acquisitions Editor: Anne Hamilton
Project Editor: Kathleen Atkins
Technical Editor: Allen Jones
Body Part No. X09-45921
To Peter and Minda—wishing you every happiness
Acknowledgments
All authors are perfectionists. Although I'm proud of the first edition of this book, doing a second edition has
allowed me not only to write about the cool new stuff in the products but also to fix the things about the first
edition I didn't like. I'm grateful for the opportunity to write this book, and thanks for that goes to my
commissioning editor at Microsoft Press, Anne Hamilton.
Warm thanks to my project editor, Kathleen Atkins, who is not only a great editor but also an excellent
photographer. She took the photograph of me that accompanies the biography at the back of this book.
Thanks to the very thorough technical editing of Allen Jones, who has contributed hugely to making my
garbled technical explanations understandable and to getting the sample code into shape. Thanks also to all
the other excellent people on the Microsoft Press team: Jennifer Harris, Joel Panchot, Julie Hatley—and
apologies to anyone else I've missed.
In the Microsoft ASP.NET product group, thanks to Susan Chory, Andres Sanabria, and Matthew Gibbs for
their help and support—and thank you for a great product! At Content Master, thanks to my colleagues, who
remain a pleasure to work with, but particularly to David Glanville, my project manager and provider of weary
sighs as I overran on the time estimates for this book yet again. (Hey, we don't write these things for profit, do
we? It's just for FUN!)
The final paragraph of acknowledgments is always thanks to the author's family. Well, it should be the first
paragraph (but I don't quite feel able to break with tradition). I give heartfelt thanks to the center of my world,
my wonderful wife, Caroline, who provides me with support and encouragement, but more particularly, love
and companionship. And thanks to my wonderful daughters, Frances and Claire: I thought teenagers were
meant to be awful, but you two are really great.
Andy Wigley
Andy Wigley is a Principal Technologist at Content Master. He works exclusively with mobile technologies and
particularly loves researching, programming, and writing about applying Microsoft .NET to mobility solutions.
This interest has led him to devise and coauthor two books: the one you are holding now, and Microsoft .NET
Compact Framework (Core Reference) with Stephen Wheelwright (Microsoft Press, 2003), which focuses on
building rich client .NET applications for Pocket PC and Microsoft Windows CE .NET devices. He has
contributed to MSDN and other publications and regularly appears at conferences, presenting on applications
of mobile technology. He's a member of the Microsoft .NET Code Wise Community, supporting the developer
community with help and advice on mobility issues.
He lives with his wife, Caroline, and their two daughters, Frances and Claire, in North Wales. When he's not
at a computer, you'll find him rock climbing and walking in the mountains.
PowerTools
At Microsoft Press, we use tools to illustrate our books for software developers and IT professionals. Tools
very simply and powerfully symbolize human inventiveness. They're a metaphor for people extending their
capabilities, precision, and reach. From simple calipers and pliers to digital micrometers and lasers, these
stylized illustrations give each book a visual identity, and a personality to the series. With tools and
knowledge, there's no limit to creativity and innovation. Our tagline says it all: the tools you need to put
technology to work.
The manuscript for this book was prepared and galleyed using Microsoft Word. Pages were composed by
Microsoft Press using Adobe FrameMaker+SGML for Windows, with text in Garamond and display type in
Helvetica Condensed. Composed pages were delivered to the printer as electronic prepress files.
Cover Designer: Methodologie, Inc.
Interior Graphic Designer: James D. Kramer
Principal Compositor: Paula Gorelick
Interior Artist: Joel Panchot
Copy Editor: Jennifer Harris
Proofreader: nSight, Inc.
Indexer: Julie Hatley
Introduction
A few weeks ago, I got my hands on my first Microsoft Windows Powered Smartphone. It's a beautiful device
and a great phone, but the first thing I noticed (and the first thing anyone else I show it to notices) is that it has
a large, high-definition color screen. It's a far cry from the three-line black-and-white text screens that
everyone was using when the first edition of this book came out.
I expect that everyone will have mobile devices with large, color screens before long. When you use the
browser on these devices, you get a readable amount of information displayed, instead of having to scroll
continuously through it. The color and high definition make it pleasurable to the eye. These kinds of browsers
could not be used on mobile communications networks until recently because of the limited bandwidth, but
over the last year, faster GPRS and CDMA2000 networks have been launched throughout the world. Faster
networks and bigger color displays mean that you can create richer, more compelling Web content for mobile
browsers, which results in a more usable, more satisfying user experience. The mobile Web is beginning to
come of age.
I don't believe that the three-line monochrome browser is doomed, although I expect it will be seen less often
on consumer communications devices. However, Internet connectivity is turning up in more and more unlikely
places, so monochrome microbrowsers might still turn up in cars, on household appliances, and on portable
electronic gadgets.
The pace of change in mobile device technology is as fast as any other computing sector, if not faster. It's
nearly a year since the first version of what is now called ASP.NET Mobile Controls was launched (previously
called the Microsoft Mobile Internet Toolkit). In that time, we've seen smart new devices such as the Microsoft
Smartphone appear, and we've also seen a migration of lower-end devices from Wireless Application
Protocol (WAP) 1.1 to WAP 2.0, which introduces a brand new markup language, Extensible HyperText
Markup Language-Mobile Profile (XHTML-MP). ASP.NET Mobile Controls have handled these developments
comfortably. Microsoft has released configuration updates throughout the year, adding support for these new
devices and markup language and demonstrating how extensible this technology really is. You can develop
applications for these new devices using exactly the same techniques you used for WAP 1.1 devices. The
powerful abstract model the developer works with hides the details of the underlying devices, allowing you to
get on with creating great applications. If you wanted to sum up the capabilities of this technology, you'd say it
is extensible, adaptable, and customizable.
Time for Enterprise Mobility Applications?
There's momentum building from different directions that makes me believe that we'll see a huge increase in
the implementation of mobility solutions in the enterprise. The devices are getting cheaper, and they have
better capabilities. The telecommunications networks are getting faster, and with the spread of Wi-Fi (802.11
wireless LAN) throughout the workplace and at hot spots in public places such as airports, railway stations,
and coffee shops, enterprises can be confident that if they equip their personnel with capable devices such as
a Pocket PC Phone Edition PDA with integrated Wi-Fi, they'll never be far from a wireless network connection
with decent bandwidth. If you develop mobile Web applications, your users can access them from the
browser in the device over Wi-Fi when they are in a location where that's available. When users can't connect
to a wireless LAN, they can connect to a GPRS or CDMA2000 network operated by a phone network
operator. (GPRS and CDMA2000 connections are sometimes known as WWAN—wireless wide area
network—to distinguish them from WLAN, which is the proper term for Wi-Fi.)
So, good devices and good networks. However, the key ingredient from an enterprise point of view is good
software. Microsoft continues to make huge investments in mobility technology. The Microsoft Windows CE
operating system that drives Pocket PC and Windows Powered Smartphone devices continues to develop
and gain new capabilities. The latest version is called Windows CE .NET and includes support for the .NET
Compact Framework, which is a "light" version of the .NET Runtime for handheld devices. Using Microsoft
Visual Studio .NET 2003, you can build .NET applications that run on handheld devices, but only those that
support the runtime, which currently are Pocket PC and Windows CE .NET devices. To reach the majority of
browser-equipped mobile devices, you need ASP.NET Mobile Controls. Again using Visual Studio .NET 2003,
you can build applications that run not on the device, but on the Web server, and that send markup to the
browser on the device. The difference is "rich" vs. "reach." The .NET Compact Framework is about rich client
applications running on only some mobile devices; ASP.NET Mobile Controls are about mobile Web
applications that work with the majority of mobile devices.
With Visual Studio .NET, developers use a single integrated development environment to build applications
for each of these scenarios. Needless to say, building ASP.NET applications requires a different skill set than
building Windows Forms applications that run on the device, but they're both built on top of the .NET
Framework, so there's a lot of commonality that can make a developer's skills more transferable between
these different disciplines.
Who Is This Book For?
We've organized this book to serve two distinct audiences. The first group is wireless developers who already
have experience developing for handheld devices. You might be new to Microsoft development and probably
haven't yet used Visual Studio .NET. We've written Chapter 1, Chapter 2, and Chapter 3 primarily with you in
mind; they introduce ASP.NET and Visual Studio .NET and walk you through the development of some
mobile Web applications. Chapter 3 explains the essential information you'll need to understand to work with
mobile Web Forms.
The second audience is those who already have experience working with the .NET Framework and Visual
Studio .NET. If you've used ASP.NET before, you'll want to skim the first three chapters to get acquainted with
the Mobile Internet Designer but then dive straight into Chapter 4 to begin working with the mobile controls.
Regardless of your background, you need to be familiar with object-oriented programming. The .NET
Framework and everything built on it is completely object-oriented. ASP.NET Mobile Controls are classes,
just like everything else in ASP.NET, and you need to understand about classes, methods, properties, and
inheritance to make full use of the mobile controls and the .NET Framework.
Perhaps surprisingly, you don't need to be familiar with HyperText Markup Language (HTML) or Wireless
Markup Language (WML). More important is familiarity with a programming language such as Microsoft
Visual Basic or Microsoft Visual C#. We want to stress that you're writing object-oriented programs that just
happen to output markup. It's quite possible to write very sophisticated ASP.NET Mobile Controls applications
without ever having to dirty your hands with device-specific markup. Later on, some familiarity with HTML,
WML, or XHTML can be useful if you want to customize your application for specific handheld devices. One
of the things you can do with the Templates feature is send "raw" markup directly to the device. Advanced
developers who want to develop their own controls must, of course, be completely familiar with the markup
languages the devices use.
All the code examples in this book are written in C#, the programming language Microsoft developed
concurrently with the .NET Framework. Our hope is that Visual Basic developers won't feel alienated by this
focus on C#. In fact, C# code and Visual Basic code are structurally very similar, and apart from the obvious
language syntax differences, the C# samples should be very readable to a Visual Basic .NET developer. On
the Web site for this book, you'll find all the sample code from this book, with versions in C# and Visual Basic
.NET. The only exceptions to this are the custom control examples in Chapter 21 and Chapter 22. These are
only in C#, not because you can't use Visual Basic (or any other language the .NET Framework supports),
but because we didn't have time to write the code!
What's in This Book?
In Chapter 1, we set the scene by describing the challenges facing mobile Web application developers and
explaining how ASP.NET Mobile Controls resolve many of those issues. In Chapter 2, we continue the
introductory theme, giving you a brief tour of Visual Studio .NET, focusing on the capabilities introduced by
ASP.NET Mobile Controls. We show you the Mobile Internet Designer, which allows you to design your
application using a drag-and-drop GUI editor, dragging mobile controls from the Toolbox and dropping them
onto a mobile Web Forms page.
Chapter 3 is in many ways the most important chapter in this book. It gives you a grounding in the important
basics of ASP.NET Mobile Controls application development. This chapter is essential reading if you're new
to ASP.NET, explaining how the request-response interactions between client and server are handled and
how actions performed by the user of the mobile device translate into events, which you trap in your code in
the server. It's also important if you already have experience with ASP.NET as you'll learn much about the
differences between ASP.NET Web Forms and ASP.NET mobile Web Forms.
Chapter 4, Chapter 5, Chapter 6, and Chapter 7 take you through each of the standard mobile controls. The
intention here was to provide a handy mini-reference to each control so that you can find out—in one
place—how to include a control in a mobile Web Forms page using Extensible Markup Language (XML)
syntax and how to access the properties and methods of the control in your code. Each control includes one
or more sample applications demonstrating how to use it.
In Chapter 8, Chapter 9, and Chapter 10, we explain the features of ASP.NET Mobile Controls that allow you
to enhance the presentation of an application. These features can be categorized into three distinct areas of
functionality: styles, property overrides, and templates. Through styles, you can define colors and fonts to
apply to the output of controls, which will be honored on those browsers that support them. Property overrides
allow you to customize your application so that for specific models or types of client devices, different values
are assigned to control properties. Templates are a powerful feature, allowing you to customize the way a list
control is displayed or to insert device-specific markup into the output sent to a particular device.
Chapters 11 through 18 describe all the other areas of functionality that you will use as a mobile Web
developer. Topics include an introduction to data handling with Microsoft ADO.NET, testing and debugging
using Visual Studio .NET and mobile device emulators, good design practice and internationalizing your
application, handling state management, packaging and deploying your application, and writing secure
ASP.NET applications.
The last four chapters in this book, Chapters 19 through 22, describe the extensibility capabilities of ASP.NET
Mobile Controls. Chapter 19 describes how to extend support in ASP.NET Mobile Controls to new devices.
You can wait until Microsoft issues an update that supports your new device, or you can add support yourself
with the help of this chapter. Most of the material in these four chapters is for the advanced developer,
although Chapter 20 describes user controls, which you can use to easily develop reusable visual
components for mobile Web applications. Chapter 21 and Chapter 22 address the authoring of custom
mobile controls in code.
What Do I Need to Use This Book?
You'll need the following software to work through the samples in this book:
Microsoft Visual Studio .NET 2003, or Microsoft Visual Studio .NET 2002 and the Microsoft Mobile
Internet Toolkit 1.0. (Download the Mobile Internet Toolkit from
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/netdevmit.asp.)
Microsoft Windows 2000, Microsoft Windows XP, or Microsoft .NET Server
The minimum hardware specification for your development PC is a Pentium II-class processor, 450 MHz with
a minimum of 128 MB (Windows 2000) or 256 MB (Windows XP or Windows .NET Server) of RAM. You'll
need around 5 GB of free hard disk space to install Visual Studio .NET 2003.
Visual Studio .NET 2003 includes emulators of a Windows CE .NET and a Pocket PC 2003 device. You can
use the browsers on these emulated devices for testing, so a real handheld device is not essential. You can
also perform initial testing of applications using Microsoft Internet Explorer. See Chapter 16 for details of
emulators from other sources that you can use for testing.
Sample Code
Most of the sample code in this book is written in C#. Many readers will prefer to use Visual Basic, so we have
implemented samples in Visual Basic as well and made all of them, both the C# and the Visual Basic
samples, available for download from this book's Web site. We hope that Visual Basic .NET developers will
download the samples and refer to those when reading the text. Fortunately, in .NET, the differences
between languages are not as pronounced as they used to be. C# and Visual Basic .NET applications are
structurally similar—only the language syntax changes—so descriptions in the text that describe how to use a
programming technique in C# should be understandable to someone referring to the Visual Basic version of a
sample.
You can download the samples from http://www.microsoft.com/mspress/books/6709.asp. Click the
companion content link in the More Information box on the right side of this page to bring up the companion
content Web page. This page has the link to download the sample code. See the instructions on that site for
how to install the samples on your own PC. Check this site for corrections and updates to the book as well.
Installing the MSDE .NET Framework Samples Database
Some of the samples in Chapter 11 use the pubs database, which installs with the Microsoft .NET Framework
SDK QuickStart samples. You don't need to install the SQL Server product on your development system
because the setup for the .NET Framework QuickStart samples will install the Microsoft SQL Server Desktop
Engine (MSDE), a stand-alone database server, if necessary.
To install the MSDE server and the sample databases, go to the C:\Program Files\Microsoft Visual Studio
.NET 2003\SDK\v1.1 folder, and double-click StartHere.htm. The Microsoft .NET Framework SDK welcome
page is displayed. Click on the QuickStarts, Tutorials, And Samples link. If you haven't already installed the
.NET Framework QuickStart samples, the page that is displayed shows two steps you must perform to install
the samples on your computer. First click Step 1: Install The .NET Framework Samples Database. When the
database has been set up, click Step 2: Set Up The QuickStarts to install all the sample databases and set
up the .NET Framework QuickStart tutorials.
Warning After you've installed the MSDE, be sure to install the latest service pack. Service Pack 3 or
later is necessary to ensure that your system does not get infected with the Slammer virus. See
http://msdn.microsoft.com/netframework/ downloads/updates/sdkfix/default.asp for details.
Using the Samples with Visual Studio .NET 2002
The samples have been developed using Visual Studio .NET 2003. You can't open the supplied project and
solution files with Visual Studio .NET 2002. If you're using Visual Studio .NET 2002 and the Mobile Internet
Toolkit 1.0, all the supplied sample code will still work, however. For any sample you want to use, you'll have
to create a new ASP.NET mobile Web application in Visual Studio .NET 2002 and then navigate to the
project folder and replace the .aspx, .aspx.cs (or .aspx.vb), Web.config, and (if supplied) global.asax and
global.asax.cs (or .asax.vb) files with those supplied in the sample. There should be no code changes
required to get the sample to work.
Support
Every effort has been made to ensure the accuracy of this book and the contents of the companion content.
Microsoft Press provides corrections for books and companion content through the World Wide Web at the
following address:
http://www.microsoft.com/mspress/support
To connect directly to the Microsoft Press Knowledge Base and enter a query, go to:
http://www.microsoft.com/mspress/support/search.asp
If you have comments, questions, or ideas regarding this book or the companion content or questions that
aren't answered by querying the Knowledge Base, please send them by e-mail to Microsoft Press at:
mspinput@microsoft.com
or by postal mail to:
Microsoft Press
Attn: Microsoft ASP.NET Mobile Devices Editor
One Microsoft Way
Redmond, WA 98052-6399
Please note that product support is not offered through the preceding mail address. For product support
information, please visit the Microsoft Support Web site at:
http://support.microsoft.com
Chapter 1: Introducing Microsoft ASP.NET for the
Mobile Web
Overview
Consider this scenario: Caroline, software engineer extraordinaire at A. Datum Corporation, is in trouble. After
a few high-profile successes, she earns recognition as a key employee. Her technical director becomes
interested in wireless Internet devices and asks her to build a mobile Web site that allows field personnel to
access their company data remotely. Figure 1-1 illustrates the challenge Caroline faces.
Figure 1-1: Designers of mobile applications face a bewildering number of choices.
After some initial research, Caroline decides Wireless Application Protocol (WAP) is the best approach.
Handsets are available, and industry support looks solid. Then the first headache appears: Caroline has to
learn a new markup language. She knows Hypertext Markup Language (HTML), but she finds WAP's
Wireless Markup Language (WML) so different that she discards her first few efforts until she succeeds in
working out how the "cards and decks" structure of a WML page works and figures out how to present
meaningful content in such a small display area. Although she wasn't naïve enough to assume that an
existing HTML Web site would transfer wholesale to a small device, she's surprised by the difficulty she has
creating a workable application given the device's small display and limited text-input capabilities. Eventually
the application takes shape, written using Microsoft Active Server Pages (ASP)—meaning that Caroline had
to refresh her knowledge of Microsoft Visual Basic Scripting Edition (VBScript) and write all the code required
to output the appropriate WML markup for her Web pages.
Soon the prototype is ready for beta testing, and Caroline is quite pleased with it. However, the testers report
that the application is confusing and unintuitive, which surprises Caroline, who carefully considered its
usability. After investigation, Caroline, who had used an emulation of a Nokia phone for testing, learns that
her users were working with Openwave browsers. Although both devices conform to WML 1.1 specifications,
the WML markup that offers the best usability on each browser differs slightly.
Caroline encounters even more problems. Field personnel at A. Datum Corporation's other main location
don't have a network operator providing WAP handsets in their metropolitan area. However, their network
operator does offer a mobile Internet service called M-mode service, which uses a different markup
language, compact HTML (cHTML). In addition, some of the prototype testers, despite seeing the potential of
the service, have recently acquired new two-way pagers, which offer text mobile Internet service—and now
they want to access the company data through the service their new pagers offer. Furthermore, the field
service managers recently received personal organizers with HTML browsers operating over wireless
modems, and they don't want to carry a WAP device as well. The technical director, looking a little
disappointed, thanks Caroline for her efforts and walks away scribbling on her indispensable personal digital
assistant (PDA), which is—of course—equipped with wireless Internet access, but not for WML.
At this point, Caroline quits the business in disgust and pursues her longtime ambition of guiding outdoor
expeditions. Once in the mountains, she finds with some relief that there are no computers in sight and that
she can't get mobile data coverage because of the surrounding peaks. Sometimes, however, lying in her
sleeping bag, she misses the excitement of software development and thinks back on the mobile project she
led at A. Datum Corporation. She realizes that the project would have succeeded if she'd had the following
capabilities:
A way to write one application that, when run, automatically generates the correct markup for all major
mobile browsers
A runtime smart enough to send not only valid markup, but also markup that actually yields optimum
usability on a particular manufacturer's browser
A presentation optimized for each type of browser—so that if, for example, the browser supports color,
the browser will use color as appropriate
The ability to lay out the user interface in a graphical user interface (GUI) editor
The ability to code in a proper object-oriented manner so that it's possible to cleanly isolate user interface
elements from application logic
Application logic that can be coded in a major language such as Microsoft Visual Basic .NET, C++, C#,
or even COBOL, with full access to data and the facilities of the underlying operating system
The ability to customize the user interface for any specific device
An extensible system that easily supports the next generation of mobile devices on the market as well as
their applications
These are features that ASP.NET Mobile Controls offer to overcome the obstacles to a successful
implementation that Caroline faced.
A Solution for the Wireless Muddle
ASP.NET Mobile Controls provide a solution for the "wireless muddle" that caused so many problems for the
developer in the preceding scenario. Wireless developers have to cope with a confusing variety of different
devices—small or large devices with different-size screens, in color or monochrome, and that require one of
the HTML, cHTML, WML, or XHTML markup languages, and quite often a specific "dialect" of one of those.
Since the first edition of this book came out early in 2002, the situation has gotten more confusing! At that
time, WAP/WML 1.1 browsers were commonplace in Europe, cHTML 1.0 browsers were predominant in
Japan, and Pocket PCs and Palm devices using an HTML 3.2 browser were the favored handheld devices for
businesses. A year later, you can walk into a shop of any of the major mobile network operators and be faced
with mobile phones with WML 1.1 or WML 1.3 browsers, Pocket PC Phone Edition and Microsoft Smartphone
devices with HTML browsers, and smartphones with WAP 2.0 browsers that require XHTML Mobile Profile
(XHTML-MP) markup, which is the successor to WML. Japanese i-mode technology, already a huge success
in Japan, is now being offered by operators in Europe and North America. PDAs and higher-end
Smartphones usually have HTML 3.2 browsers, although the version of Pocket Internet Explorer included in
the latest release of Microsoft's operating system for handheld devices, Microsoft Windows CE .NET, accepts
HTML 4.0 markup.
How then do you create an application that works with a significant number of these devices? If you're lucky
and you can control which devices are issued to your users, you can standardize on one device and one
technology. Few of us will have that luxury, however. Even if you build an application for one specific device,
the speed of technological change in this industry means that you will quite likely be looking at a major rewrite
a year down the line, when you want to take advantage of a new generation of handheld devices.
The answer is to make the technology on the client device an irrelevance—or to put it another way, to use
middleware on the Web server that takes care of worrying about the specific requirements of a particular
client device on your behalf. You develop a single application using ASP.NET Mobile Controls, deploy it to a
Windows Web server running Internet Information Services (IIS) and the Microsoft .NET Framework, and that
application works with over 200 different kinds of mobile devices from many different vendors, each with its
own specific requirements of markup language and screen size, as illustrated in Figure 1-2. Microsoft
regularly releases Device Update packs for ASP.NET Mobile Controls that add support for still more
handheld devices.
Figure 1-2: The ASP.NET Mobile Controls use adaptive rendering to support over 200 different handheld
devices from a single application.