ASRNET mobile controls give developers the tools they need to create websites and applications that are accessible from a variety of mobile client devices. They are available in an optional add-in for ASP. NET called the Microsoft Mobile Internet Toolkit (MMIT), which can be installed on top of the .NET Framework. The first section of this book introduces the concepts of mobile development, and walks the reader through the fundamentals of WAR WML, and HTTP. The core of the book deals with how to use the mobile controls supplied in the MMIT to produce targeted output suitable for viewing on a range of mobile devices. These concepts are then applied to developing mobile applications with Visual Studio .NET. The book concludes with a case study, bringing together everything that has been discussed, in a functional mobile application.
Who is this book for?
This book introduces ASRNET developers to the concepts and controls they need to create meaningful content for mobile client devices. Readers of this book should be familiar with the basics of ASP. NET and C#. This book is written in C# throughout, with code samples available to download from http://www, wrox.com/in both C# and Visual Basic .NET.
What does this book cover?
Mobile Web Forms and Mobile Site Design
Navigating a Mobile Site
Data Binding
Validation Controls
Styling Page Output
Writing Custom Mobile Controls
Security
Visual Studio .NET and the MM)T
Introduction
Who Is This Book For?
What Does This Book Cover?
What Do I Need To Run ASP.NET?
Conventions
Customer Support
How To Download The Sample Code For The Book
Errata
E-mail Support
p2p.wrox.com
Why This System Offers The Best Support
Chapter 1: Introducing The .NET Mobile World
.NET
Tone Your Web Application With ASP.NET
ASP.NET Server Controls
HTMLControls And WebControls
User Controls
Validation Controls
The Mobile Thing
A Few Compatibility Issues between ASP.NET and Mobile Controls
Error Handling and Reporting
Tracing
Session State and Cookies
Summary
Chapter 2: Prepare For Development!
Installation
Microsoft Mobile Internet Toolkit
The Nokia Mobile Internet Toolkit
The Openwave Simulators
The Microsoft Mobile Explorer
Virtual Directories And Web Applications
What Is A Virtual Directory?
Setting Up A Virtual Directory
Permissions In IlS
Testing Our Installation
Help - It's Not Working!
Summary
Chapter 3: Mobile Communication
The Importance Of Being Mobile
Mobile Is Better
Mobile Business
The WAP Experience
The HTTP Protocol
The HTTP Request
The HTTP Response
The WAP Protocol
The Transmission Protocol
The Presentation Format
How Successful is WAP Technically?
A Good Protocol for Wireless Data
A Presentation Problem
Lessons from WAP
Summary
Chapter 4: The Mechanics of ASP,NET Mobile Forms
.NET Framework Basics
The Common Language Runtime (CLR)
.NET Class Library
Lifecycle Of A Mobile Form
What's Happening In The Lifecycle
Mobile Form Processing
Initialization
Event Handling
Device Detection
Rendering
Cleanup
Mobile Forms Versus Web Forms
Anatomy 101
Web Page
Page Directive
Server~side Script
Mobile Page
Page Directive
Register Directive
Server-side Controls
Summary
Chapter 5: Structuring Mobile Web Forms Pages
Mobile Web Form Structure
The
The
Summary
Chapter 6: Interacting With Users
The User Experience
The Control
The Control
The Control
The Control
Something Else To Take With You
Summary
Chapter 7: Navigating A Mobile Site
Hyperlinks
Uniform Resource Locaters (URLs)
The Control
Using The SoftKeyLabel Attribute
Creating A Menu With The Control
Wiring The Mobile Site
The Control
Image Types
Images Supported By Devices
The Control
Summary
Chapter 8: List Controls and Data Binding
The Control
Interacting With The Control
Navigation And Style With
The Control
The Control - Radio Button List
The Control - Check Box List
The Control - List Box
The Control - Multi Select List Box
Data Access
Getting Started
ADO.NET Classes
Types Of Providers
Connecting To The Data Source
Command And DataReader Classes
Traffic Database
Summary
Chapter 9: Data Binding
What Is Data Binding?
Data Binding A Control With An ArrayList Object
Data Binding The Control With A DataReader
Data Binding The Control
Data Binding The Control
Summary
Chapter 10: Validation controls
How Do Validation Controls Work?
Common Properties
Control-Specific Properties
Device-Specific Behavior
Putting Validation Controls to Work
The CompareValidator
Properties
The RangeValidator Control
The RegularExpressionValidator
The RequiredFieldValidator
The CustomValidator
The ValidationSummary
Properties
Summary
Chapter 11: Working With Rich Controls
Using the Rich Controls
The AdRotator
Properties
Properties Set In The Mobile Page
AdvertisementFile
The Calendar Control
Summary
Chapter 12: Styling Page Output
Style Attributes
Style Properties
Stylesheets
Device Capabilities
Pagination
A Word Of Caution
Device Specific Rendering
Summary
Chapter 13: Writing Controls
User Control
Custom Controls
Summary
Chapter 14: New Device Support
Configuring a Device
Request Headers
Custom Control Adapters
Summary
Chapter 15: Web Services
Web Services Refresher
Smart Devices
Summary
Chapter 16: Security, Cookies, and State Management
.NET Security Overview
Code Access Security
Role-Based Security
Security In The Mobile Internet Toolkit
Authentication
Windows Authentication
Forms Authentication
Passport
Further Reading
Session State
ViewState In Mobile Pages
ViewState Session History
Cookieless Sessions
Other Considerations
Summary
Chapter 17: Introducing Visual Studio .NET
Installation
Start Page
Getting Started
What's New
Online Community
Headlines
Search Online
Downloads
Web Hosting
My Profile
Creating a Project
The Designer Window
The Toolbox Window
The Solution Explorer Window
The Properties Window
The Dynamic Help Window
Testing A Project
The Output Window
The Task List Window
The Debugging Window
Advanced Topics
The Server Explorer
The Object Browser
Setting Options in Visual Studio ,NET
Summary
Chapter 18: Using Visual Studio .NET For Mobile Applications
Introduction
Designing A Mobile Application
Adding Logic
Code-behind
Testing A Mobile Application
Summary
Chapter 19: Maitre D' Mobile Application
Overview of the Application
Maitre D'
Target Audience
Gathering Requirements
Architecture
MaYtre D' Database
The Maitre D' Web Service
MaitreDWebService.asmx
Testing
The User Interface
Making A Reservation
Placing A Carryout Order
Seeing An Existing Order
View Menu
The Display Logic - MaitreDMobileForm,aspx
Application Logic - MaitreOMobileForm.aspx.cs
Summary
Appendix A: Configuring Environment Variables
Index
ASP.NET Mobile Controls give developers the tools they need to create interactive web sites that are accessible from a wide range of mobile client devices. They are contained in an optional ASP.NET add- in, called the Microsoft Mobile Internet Toolkit, that comprises the controls themselves, together with additional functionality for integrating them into Visual Studio .NET.
This book is divided into three principal sections:
An introduction to WAP, WML, and the conceptual ideas surrounding programming for clients with limited resources
An explanation of how to use each of the ASP.NET Mobile Controls to produce targeted output tailored to each individual device that views your page
A demonstration of how to utilize the controls in the Visual Studio .NET development environment, concluding with a complete case study mobile application
This book introduces the ASP.NET programmer to all the concepts and controls that they need to understand in order to create meaningful content for mobile client devices.
Who Is This Book For?
This book is aimed at anyone who is building, or planning to build, applications for mobile devices using the .NET Framework. Experience of ASP.NET is required, as is some exposure to C#. The reader of this book should feel comfortable about creating ASP.NET applications and not feel lost when viewing simple C# code.
A brief refresher of the basics of ASP.NET is included, but it may prove too advanced for the complete novice.
If you want more information about ASP.NET, to complement this book, you may find Beginning ASP. NET using C# useful (Wrox Press, ISBN: 1-861006-15-2).
What Does This Book Cover?
This book is written against the Release Candidate of the Microsoft Mobile Internet Toolkit, running on the Release Candidate of the .NET Framework, and as such is designed to provide code that runs with the final release of .NET. The book covers the following topics:
An Introduction To The ASP. NET Mobile Controls
In Chapters 1 to 3, we'll talk about the principals of mobile communication, the strengths and weaknesses of mobile clients, and begin to discuss how developers need to think differently in order to maximize the potential of these devices. We'll go on to walk through the installation and setup procedures of the MMIT, and a selection of client browsers. We'll also recap the basics of how to serve your files using ASP.NET, and the mobile controls. We then move on to look at mobile communication in more detail, considering the communication technologies used, where those technologies have come from, and where they might be going in the future.
The ASP. NET Mobile Controls
In Chapters 4 to 9, we'll look in detail at the ASP.NET Mobile Controls. We'll begin by considering the lifecycle of an ASP.NET Mobile Web Form compared with its cousin, the traditional ASP.NET Web
Form. Then we'll move on to consider the basic controls provided by the Microsoft Mobile InternetToolkit and how they can be applied in a variety of ways to provide meaningful results. We'll demonstrate these ideas through the use of simple Try It Out examples, and present the output in a pair of different browsers so the differences in presentation between clients can clearly be seen.
Advanced Functionality And Optimization
In Chapters 10 to 16 we'll look at some of the more advanced ASP.NET Mobile Controls, such as those associated with validating user inputs, and dealing with rich outputs. We then move on to discuss how you can adjust the stylingof the output your controls produce, and how to secure your mobile web applications against unauthorized access. We'll also consider how you can add support to the MMIT for new devices, and create your own mobile controls.
Visual Studio .NET Integration
The final chapters of the book will look at how to use Visual Studio .NET to create both standard, and mobile web applications. We'll walk you through the functionality provided by the IDE, and show how easily the MMIT is integrated into it. Finally, we'll conclude the book with a Case Study, created using the MMIT in Visual Studio .NET, bringing together all the concepts we've outlined in the book and using them to solve a real-world problem.
What Do I Need To Run ASP. NET?
In order to answer this, we need to consider the role that we'll be playing in this book - namely that of the web developer or webmaster. In this role, we'll be writing web pages, publishing them on a web server, and testing them to see what they look like and whether they work. This is just a list of items that you will need. Don't worry if you can't locate all the bits and pieces just yet, as we'll be looking at where to get them from in the opening chapter:
You'll need the following things to be able to use this book:
The .NET Framework (this is available as a public download from Microtsoft)
An ASP.NET compliant web server (ASP.NET requires IlS 5.0 or later, which means you'll need to be running either Windows 2000 Professional or above, or Windows XP Professional)
The Microsoft Mobile Internet Toolkit (this is also available as a free download from Microsoft. Details are given in Chapter 2)
A selection of client device emulators for testing purposes (many are available as free downloads. Details are given in Chapter 2) Optionally:
Visual Studio .NET, for the integration chapters at the end of the book, and for the Case Study
The code in this book is designed to be run using the full release version of the .NET Framework, and as such it may not run correctly on pre-release versions.
Conventions
We've used a number of different styles of text and layout in this book to help differentiate between the different kinds of information. Here are examples of the styles we used and an explanation of what they mean.
Code has several fonts. If it's a word that we're talking about in the text - for example, when discussing a For ... Next loop, it's in this font. If it's a block of code that can be typed as a program and run, then it's also in a gray box:
<%0 Page language="c#" runat="server" %>
Sometimes we'll see code in a mixture of styles, like this:
<%@ Page language="c#" runat="server" %>
When this happens, the code with a white background is code we are already familiar with; the line highlighted in gray is a new addition to the code since we last looked at it.
Advice, hints, and background information come in this type of font.
Important pieces of information come in boxes like this.
Bullets appear indented, with each new bullet marked as follows:
Important Words are in a bold type font.
Words that appear on the screen, or in menus like File or Window, are in a similar font to the one you would see on a Windows desktop.
Keys that you press on the keyboard, like Ctrl and Enter, are in italics.
Customer Support
We always value hearing from our readers, and we want to know what you think about this book: what you liked, what you didn't like, and what you think we can do better next time. You can send us your comments, either by returning the reply card in the back of the book, or by e-mail to feedback@wrox.com. Please be sure to mention the book title in your message.
How To Download The Sample Code For The Book
When you visit the Wrox site, http://www.wrox.com/, simply locate the title through our Search facility or by using one of the title lists. Click on Download in the Code column, or on Download Code on the
book's detail page.
The files that are available for download from our site have been archived using WinZip. When you have saved the attachments to a folder on your hard-drive, you need to extract the files using a decompression program such as WinZip or PKUnzip. When you extract the files, the code is usually extracted into chapter folders. When you start the extraction process, ensure your software (WinZip, PKUnzip, and so on) is set to use folder names.
Errata
We've made every effort to make sure that there are no errors in the text or in the code. However, no one is perfect and mistakes do occur. If you find an error in one of our books, like a spelling mistake or a faulty piece of code, we would be very grateful for feedback. By sending in errata you may save another reader hours of frustration, and, of course, you will be helping us provide even higher quality information. Simply e-mail the information to support@wrox.com, where your information will be checked and, if correct, posted to the errata page for that title, or used in subsequent editions of the book.
To find errata on the web site, go to http://www.wrox.com/, and simply locate the title through our
Advanced Search or title list. Click on the Book Errata link, which is below the cover graphic on the book's detail page.
e-mail Support
If you wish to directly query a problem in the book with an expert who knows the book in detail then e- mail support@wrox.com, with the title of the book and the last four numbers of the ISBN in the subject field of the e-mail. A typical e-mail should include the following things:
The title of the book, last four digits of the ISBN, and page number of the problem in the Subject field.
Your name, contact information, and the problem in the body of the message.
We won't send you junk mail. We need the details to save your time and ours. When you send an e- mail message, it will go through the following chain of support:
Customer Support - Your message is delivered to our customer support staff, who are the first people to read it. They have files on most frequently asked questions and will answer anything general about the book or the web site immediately.
Editorial - Deeper queries are forwarded to the technical editor responsible for that book.
They have experience with the programming language or particular product, and are able to answer detailed technical questions on the subject.
The Authors - Finally, in the unlikely event that the editor cannot answer your problem, he or she will forward the request to the author. We do try to protect the author from any distractions to their writing; however, we are quite happy to forward specific requests to them.
All Wrox authors help with the support on their books. They will e-mail the customer and the editor with their response, and again all readers should benefit.
The Wrox Support process can only offer support to issues that are directly pertinent to the content of our published title. Support for questions that fall outside the scope of normal book support, is provided via the community lists of our http://p2p.wrox.com/forum.
p2p.wrox.com
For author and peer discussion join the P2P mailing lists. Our unique system provides programmer to programmerTM contact on mailing lists, forums, and newsgroups, all in addition to our one-to-one e-mail support system. If you post a query to P2P, you can be confident that it is being examined by the many
Wrox authors and other industry experts who are present on our mailing lists. At p2p.wrox.com you will find a number of different lists that will help you, not only while you read this book, but also as you develop your own applications. Particularly appropriate to this book are the aspx and aspx_professioual lists in the .NET category of the web site.
To subscribe to a mailing list just follow these steps:
1. Go to http://p2p.wrox.com/
2. Choose the appropriate category from the left menu bar
3. Click on the mailing list you wish to join
4. Follow the instructions to subscribe and fill in your e-mail address and password
5. Reply to the confirmation e-mail you receive
6. Use the subscription manager to join more lists and set your e-mail preferences
Why This System Offers The Best Support
You can choose to join the mailing lists or you can receive them as a weekly digest, If you don't have the time, or facilities, to receive the mailing list, then you can search our online archives. Junk and spam mails are deleted, and your own e-mail address is protected by the unique Lyris system. Queries about joining or leaving lists, and any other general queries about lists, should be sent to 1 is t support ~p2p. wrox. com.