About the Book
A comprehensive reference for developing mobile
Web applications with ASP.NET Mobile Controls, which ships with Visual
Studio .NET 2003
This update of a popular Microsoft Press®
title 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. With this title, programmers learn how to incorporate dynamic
access to data with ADO.NET, plus how to deliver content from a single
ASP.NET page to multiple client browsers on devices with limited display
and input capabilities.
Related Books
The Microsoft® Platform Ahead
Network Programming for the Microsoft® .NET Framework
Microsoft® .NET and J2EE Interoperability Toolkit
Table of Contents
Acknowledgments
xv
Introduction xvii
1 Introducing Microsoft
ASP.NET for the Mobile Web 1
A Solution
for the Wireless Muddle 4
Developing
with Mobile Web Forms 5
Abstracting the Mobile Device User Interface 5
Using Mobile Web Forms Controls 6
Working with Mobile Web Forms Using .NET Tools 7
Implementing Code 8
Consuming Events 9
Building
Mobile Solutions with Microsoft .NET 9
A Powerful
Solution for Mobile Web Application Development 12
2 Getting Started
13
Setting
Up Your Development System 13
Creating
Your First Mobile Web Applications 16
Creating a Mobile Web Project with Visual Studio .NET 17
Using Solution Explorer and the Properties Dialog Box 19
Building the User Interface with the Toolbox 20
Building and Running Your Application 21
Testing
with a Mobile Phone Emulator 22
Setting Up the Openwave Simulator 23
Using the Simulator for Testing 24
Working
with the Mobile Internet Designer 26
The Mobile Web Forms Page and Form Control 27
Working with Multiple Form Controls 29
Backward and Forward Navigation in Mobile Web Applications 32
Device-Specific Rendering of Complex Controls 33
Basic
Design Principles 35
3 Programming ASP.NET Mobile
Web Forms 39
Understanding
.aspx Files and Code-Behind Modules 40
The Code-Behind Technique 40
Design and HTML Views 42
The Inline Coding Technique 45
The MobilePage Class 47
Properties of the MobilePage Class 48
Using
Events and Event Handlers 49
Programming
State Management in ASP.NET 56
Persisting Class Members 58
Building and Testing the Application 61
Accessing
.NET Framework Classes 63
Building and Testing the Application 66
Understanding the Application Life Cycle 66
Writing
Applications with a Text Editor 68
Building the User Interface 68
Creating the Code-Behind Module 69
Building and Testing the Application 72
4 Programming the Standard
Controls 75
How to
Use the Control Descriptions 75
Introducing
the Controls: Class Hierarchy 76
Common
Mobile Controls Behavior 78
Container
Controls 83
Containment Rules 84
Form Controls 85
Panel Controls 91
Core
Controls 93
Command Controls 94
Image Controls 99
Label Controls 105
Link Controls 108
TextBox Controls 111
TextView Controls 117
5 Special-Purpose Controls
and Validation Controls 121
Special-Purpose
Controls 122
Calendar Control 122
PhoneCall Control 128
AdRotator Control 131
Validation
Controls 136
Common Behavior of the Validation Controls 138
RequiredFieldValidator Control 140
CompareValidator Control 144
RangeValidator Control 148
RegularExpressionValidator Control 152
CustomValidator Control 157
ValidationSummary Control 161
Validation Controls Example 165
6 Programming the List
Controls 169
Building
Static or Data-Bound Lists 171
The SelectionList
Control 175
Syntax 175
Properties and Events 176
Using the SelectionList Control 178
The List
Control 186
Syntax 186
Properties and Events 187
Using the List Control 189
The ObjectList
Control 196
Syntax 197
Properties and Events 198
Using the ObjectList Control 202
7 Using the Downloadable
Controls 219
Using
the Custom Controls 219
Adding the Controls to the Toolbox 220
Copying the Control Assembly to Your Application 222
Configuring Your Application to Use Custom Controls 223
The MobileCheckbox
Control 224
Configuring Your Application 224
Syntax 225
Properties 226
Using the MobileCheckbox Control 227
The MobileMultiLineInput
Control 228
Installation 230
Configuring Your Application 230
Syntax 231
Properties 231
Using the MobileMultiLineInput Control 232
The MobileDynamicImage
Control 233
Installation 235
Configuring Your Application 235
Syntax 236
Properties 237
Using the MobileDynamicImage Control 238
8 Programming Styles and
Style Sheets 241
Using
Mobile Control Style Properties and the StyleSheet Control 241
Using Style Properties 243
Using the StyleSheet Control 248
Pagination
and Styles 256
Using Pager Styles in Style Sheets 258
Working
with Styles in Visual Studio .NET 259
The Styles Editor 259
Using
Cascading Style Sheets (CSS) 260
Managing Cascading Style Sheets 262
Programming your own CSS Style Sheet 262
9 Customizing with Property
Overrides and Templates 267
Customization
Overview 267
Property Overrides 268
Templates 268
Writing
Device Filters 269
Programming
<DeviceSpecific> and <Choice> Elements 282
Device-Specific
Customization with Property Overrides 286
Using
Templated Controls 288
Using the Form Control's <HeaderTemplate>, <FooterTemplate>, and
<ScriptTemplate> Elements 291
Using the Panel Control's <ContentTemplate> Element 298
Working with Controls in Form and Panel Templates 302
Defining Templates Using Visual Studio .NET Tools 305
Defining Templates Within Style Sheets 308
10 Advanced List Control
Programming 313
Using
the Advanced Data Binding Features of the List Controls 313
Defining Static List and SelectionList Items 313
Binding to a Data Collection 314
Understanding Data Binding and ViewState 317
Why the DataItem Property Is Sometimes null 320
Overriding
Single-Field Display in the List Controls 321
Overriding Single-Field Display in SelectionList and List Controls 321
Overriding Single-Field Display in ObjectList 322
Using
Templates in List and ObjectList Controls 323
Programming the List Control Templates 324
Programming the ObjectList Control Templates 332
Using the ObjectList Control's <ItemDetailsTemplate> 336
Working with Controls in Templates Programmatically 341
Accessing Controls in List and ObjectList Templates from Code 343
11 Accessing Data
347
Using
ASP.NET Declarative Data Binding 347
Using
ADO.NET 352
Understanding the ADO.NET Objects 353
Using a DataReader Object for Read-Only Data Access 355
Using a DataSet Object for Data Binding 356
Creating a Mobile Web Application to Update a Database 358
Building
Data Components with Visual Studio .NET 364
Using Server Explorer 364
Creating Data Components 365
Using a Data Component in a Web Application 369
Learning
More About ADO.NET 372
12 State Management 373
Session
State 374
Using the Session Object 376
Working with Cookies 378
Using Munged URLs 379
To Cookie or Not to Cookie 380
Hidden
Variables 381
ViewState
384
Application
State 388
Using Application State in Global.asax 389
Things to Consider When Using Application State 395
13 Enhancing Application
Performance 397
Programming
and Configuration Techniques 397
Turn Off Debug Support in Your Release Builds 397
Disable ViewState If It's Not Required 398
Disable Session State If It's Not Required 398
Cache Data in the Application Object 399
Use Custom Pagination with the List Controls 399
Don't Perform Unnecessary Processing on Postback 400
Concatenate Strings Using System.Text.StringBuilder 400
Optimize SQL Server Data Access 400
Explicitly Declare Object Types in Visual Basic .NET 401
Caching
401
Using Output Caching 401
Using Fragment Caching 410
Using Data Caching 411
14 Multilingual and Multicultural
Web Applications 413
Building
Multilingual and Multicultural Mobile Web Applications 413
Defining
Culture for Formatting Strings, Dates, and Times 414
Creating
and Using Resource Files 418
Defining
Character Set Encodings 424
15 XML Web Services
427
Introduction
to XML Web Services 427
Using XML Web Services in Web Applications 428
Managing Session and Application State 429
Creating
an XML Web Service 429
Creating an XML Web Service Using a Text Editor 429
Creating an XML Web Service Using Visual Studio .NET 430
Consuming
an XML Web Service 432
Consuming XML Web Services Using Visual Studio .NET 432
Defining
XML Web Service Behavior 437
Working
with Data Types 440
Accessing
Data 444
Considerations
for Mobile Devices 449
16 Debugging, Testing with
Emulators, and Handling Run-Time Errors 451
Debugging
Mobile Web Applications 452
Configuring Applications to Support Debugging 453
Using
the ASP.NET Trace Facility 455
Enabling Page-Level Tracing 456
Enabling Application-Level Tracing 457
Adding Your Own Trace Statements 459
Executing Blocks of Code in Trace Mode 460
Handling
Errors 461
Implementing Custom Error Pages 461
Handling Errors Programmatically 464
Testing
with Emulators and Real Devices 467
Using Pocket Internet Explorer for Application Testing 468
Using a Pocket PC Emulator 469
Testing with a Microsoft Smartphone Emulator 471
Testing with Mobile Phone Emulators 472
Integrating an Emulator into Visual Studio .NET 482
17 Packaging and Configuration
485
Packaging
and Deploying an Application 486
Copying an Application 486
Creating a Web Setup Project 490
Deploying
Applications to Servers Running Different Versions of the .NET Framework
494
Installing .NET Framework Runtime on a Web Server 496
Device Update Packs 497
Configuring
Applications 497
Understanding the .NET Configuration Files 498
Web.config Configuration Example 501
Building
ASP.NET Applications with Integrated Desktop and Mobile Access 502
Tailoring Functionality to the Client Device 503
Implementing a Redirect Page for the Mobile Web Site 503
18 ASP.NET Application
Security 507
Encrypting
Data Transfers Between Client and Server 507
Providing
Authentication 509
IIS Authentication 510
ASP.NET Authentication 513
Forms Authentication 514
Passport Authentication 524
Windows Authentication 529
User
Authorization 530
Impersonating a User 531
URL Authorization 532
19 Supporting New Clients
535
Defining
Mobile Devices in Configuration Files 536
Device Configuration Files in .NET Framework 1.1 538
Supporting
a New Client 539
Identifying the Device 540
Identifying Device Capabilities 543
Configuring
Device Adapters 551
The Role of Device Adapters 551
Using Device Adapter Sets 553
Defining a Device Adapter Set 554
20 Building a Reusable
User Interface as User Controls 559
Building
a User Control 559
Creating a Simple User Control 560
Coding a User Control Module 560
Using
a User Control in a Web Forms Page 561
User
Control Example 561
Implementing Properties in a User Control 564
Displaying the Properties of the User Control 566
Responding to Events in a User Control 570
21 Creating Custom Controls
by Inheritance and Composition 575
Building
Controls in Code 575
Understanding the Control Life Cycle 576
Building
Controls by Inheritance 580
Using a Compiled Custom Control 584
Building
Controls by Composition 586
Creating the Child Controls in a Composite Control 587
Processing Postback Data 591
Raising Custom Events 592
Managing ViewState 596
22 Programming Device Adapters
and Building Controls from Scratch 601
Building
Controls from Scratch 602
The Control Life Cycle 602
The Role of Device Adapters 606
Building
Simple Custom Controls and Device Adapters 612
A Simple Control with Device Adapters for HTML and WML 613
Writing Device Markup with the MobileTextWriter Classes 617
Handling Style Attributes in Device Adapters 617
Using Custom Controls and Device Adapters 620
Building
a Data Bound Custom Control 623
Supporting Internal and Custom Pagination 629
Implementing the OnDataBind Event 632
Supporting
ViewState in a Custom Control 634
Saving Control Properties to the ViewState Object 635
Understanding the IStateManager Interface 636
Using PrivateViewState 640
Implementing
a Custom MobileControlBuilder Class 641
Enabling
Client Postback in a Custom Control 643
Implementing Postback for the CMTable Control 644
Processing
Postdata 649
Implementing Postdata Processing in the CMTable Control 649
Providing Different User Interfaces in the DeviceAdapter Classes 651
Adding Child Controls in a Device Adapter Class 654
Developing
a Templated Custom Control 658
Implementing Support for Templates 658
Implementing Template Support for a Data Bound List Control 660
INDEX 667 |