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
Andy Wigley is a Principal Technologist a technical authoring company Content Master in the UK, focusing on mobile technologies. He has worked with WAP from the early days, and worked with co-author Peter to develop the UK's first operational payments service for WAP clients. He has contributed to MSDN and other publications and regularly appears at conferences, presenting on applications of mobile technology. He has been involved in software engineering for more than 15 years, much of that time at Digital Equipment Corporation, working on projects as diverse as high-performance messaging, electronic document exchange, and laboratory robotics.
Peter Roxburgh works as a technologist for Content Master Ltd., a technical authoring company based in the United Kingdom. He graduated with a first class degree with honours in business and has since followed a diverse career path. From his home in the medieval town of Conwy, North Wales, he writes training courses for mobile developers. He has also written and contributed to a number of journals and Web sites on cutting-edge mobile technologies.