The Barnes & Noble Review
If you've been around the block with Active Server Pages, the odds are pretty good that you're welcoming ASP.NET. Yes, you'll have a lot to learn, but you may be chafing at the limitations of "classic" ASP. And it sure would be great to leverage your hard-won ASP skills in more sophisticated web applications and web services. In Inside ASP.NET, Scott Worley focuses on helping you do just that.
Writing for experienced ASP developers, he covers every significant aspect of ASP.NET development. You'll find detailed coverage of ADO.NET, which presents a new data access programming model that will be the foundation of all the data-aware applications you develop with .NET. There's in-depth coverage of ASP.NET's cool Web Forms, which finally bring the "Visual"-whatever forms-based paradigm to web software development.
The book's nuts-and-bolts coverage includes state management, XML support, component services, messaging and directory services, application localization and globalization, the creation of custom controls, and even development for mobile devices. There's plenty of source code -- and the book ends with a complete "online task management" case study application designed to drive home all of the book's key concepts.
Bill Camarda is a consultant, writer, and web/multimedia content developer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. He served for nearly ten years as vice president of a New Jerseybased marketing company, where he supervised a wide range of graphics and web design projects. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.
Written for experienced software and web developers, this book presents information on the technologies and concepts introduced in Microsoft's new development platform, .NET, covering topics such as ADO.NET, XML Web Services, cache control, globalization, and mobile device development. Numerous source code examples illustrate concepts, and a full ASP.NET-based online task management application is used as a final project/case study. Worley is a freelance IT consultant specializing in Microsoft-based technologies. Annotation c. Book News, Inc., Portland, OR
Read an Excerpt
16: Mobile Device
Mobile devices are becoming increasingly popular. Over the past
few years, mobile phones have become so common that it is more of a rar-ity
to see someone without one. Personal Digital Assistants (PDAs), such as
Palm Pilots, also are popular. Combine this with the fact that the Internet
is everywhere. It goes without saying that tremendous opportunity exists
for the savvy web developer to take advantage of this current state of
So, how can a developer take advantage of this? Consider the following:
Most people use the Internet as a means of finding information. Ironically, it
is not always possible to get to an Internet PC or Mac; however, most people
have more convenient access to a mobile phone or PDA.This means
that there is an enormous, untapped market for mobile Internet services.
After all, imagine being able to use your mobile device not only for sending
and receiving your email, but also for receiving information from the sports
and news feeds or the company you work for, or being able to book and
purchase tickets through online services.The possibilities are limitless!
This chapter introduces the mobile device types you can develop, and
provides a brief overview of the underlying technology used for writing
applications for mobile devices:
This chapter provides an overview of the ASP.NET Mobile Internet Toolkit
(SDK designed for developing Mobile Device applications). It also explains
some issues dealing with mobile device development and some key differ-ences
between ASP.NET forms and controls, and ASP.NET Mobile forms
and Controls. From here, it describes each Mobile control and gives exam-ples
of their uses. Finally, a brief overview of the mobile device support in
the application presented in Chapter 17, "Putting It All Together" is
- Covering Wireless Application Protocol (WAP)
- Wireless Markup Language (WML)
- WMLScript (the script language for WML)
Software You Need for This Chapter
To use the examples in this chapter, your development machine has to have the following software installed as
well as ASP.NET:
- Mobile Internet Toolkit—This can be downloaded from http://www.asp.netwww.asp.net .
- A WAP-enabled Microbrowser or emulator—this book uses Openwave UP Simulator 4.1. For the
examples in this book, you can download this emulator from http://www.phone.com .
Wireless Application Protocol (WAP)
The WAP architecture is not that different from the WWW architecture. In
fact, the WAP architecture is based on the existing WWW architecture,
which means if you understand the WWW architecture, you can understand
the WAP architecture.
Most of the technology developed for the Internet has been designed
with the desktop user in mind, which in itself presents some rather interesting
issues when developing Mobile Internet Device applications. For
instance, a desktop user has a large display with which to view, a keyboard
for data entry, and a fast Internet connection. Compare this to the mobile
device user who has a limited display area and limited data entry ability.
The WAP architecture, although based on existing web technology, has
numerous optimizations for wireless data transfer. Most of these optimizations
deal with the fact that the wireless data communications technology
available to the public has a small bandwidth capacity. In most cases, the
bandwidth capacity is less than 15Kbps, which is considerably less when
compared to conventional web browsing technology, which runs at an average
minimum of 56Kbps.
When a mobile device user requests a web page, the following request and
response process occurs:
- The user requests a URL from his Microbrowser.
- . The WAP browser encodes the request into WML format and then sends
the request to a WAP gateway.
- The WAP gateway receives the WAP request, converts the WAP request
into an HTTP request, and then sends it to a web server.
- The web server receives the HTTP request, performs whatever processing
is required, and then sends back an HTTP response to the WAP gateway.
- The WAP gateway receives the HTTP response, converts the HTTP
response into a WAP response, and then sends it to the WAP device that
- The WAP Microbrowser software receives a WAP response and renders
it to the mobile device display.
The WAP Forum is an association that developed the WAP standard. It is made up of more than 500 members
worldwide. It has the sole objective of promoting the WAP standard and assisting companies in the adoption of
For more detailed information on the WAP architecture, go to the WAP Forum web site at www.wapforum.org .
Wireless Markup Language (WML)
The WAP architecture also includes a markup language that is similar to
HTML in structure; this is called WML. This markup language is used to
render information back to the user of a mobile device through a
WML is not an overly complex language, and it benefits from being based
on HTML; however, the similarity is only in the structure of the syntax. In
Listing 16.1, you can see a simple WML application.
In line 4, you can see the <wml>element.This element outlines what is
referred to as a deck, a collection of cards and forms for a mobile device
application. In line 5, we encounter the first <card>element. A <card>element
is used like a page. It contains all the rendering commands for a single
screen of data on a mobile device. The WML file can have more than one
card nested inside the <wml>elements. After the card definition, we use a <p>
tag to surround any content we need to display. The <p>is not optional—it
has to be used or the mobile device will not render any of the content for
the card. Line 7 contains text to display on the device.
Figure 16.1 shows the screen after the mobile device receives the
So, now you have had a brief look at WAP and WML. It's time to see how
this all relates to the Mobile Device SDK for ASP.NET. Table 16.1 outlines
some key elements used in WAP/WML development and explains the
equivalent elements in ASP.NET...
You can use <wml>elements inside ASP.NET mobile forms without any problems. However, it is better to use
ASP.NET controls because the mobile control's toolkit can generate either WML or HTML depending on the capa-bilities
of the device to which it is rendering.
Creating a Mobile Device Application
ASP.NET Mobile controls are defined as elements in exactly the same man-ner
as regular ASP.NET controls.The only thing you have to do with
Mobile controls is make sure that at the top of your web page, you register
the Mobile Internet Toolkit controls and namespace as shown:
01 <%@Page Inherits="System.Web.UI.MobileControls.MobilePage " Language=="vb " %%>
02 <%@Register TagPre .x="mobile " Namespace=="System.Web.UI.MobileControls "
03 Assembly="System.Web.Mobile " %%>
On the first line, the Web Form properties are inherited from the
System.Web.UI.MobileControls.MobilePage class. This class provides the core
functionality of a mobile device web page. Also, the language is set for any
script on the web page to use Visual Basic .NET. The second line registers
the TagPre .x to mobile for the namespace
System.Web.Mobile.UI.MobileControls . This enables access to a Mobile control
without having to type in the long namespace first. For more on this, see
Chapter 2,"Developing Applications with ASP.NET."
After this has been done, you are ready to start using the Mobile Internet
Toolkit controls to build your application.
The Form Element
The Form element is required for every single mobile device web page without
exception.You can have more than one form to a Web Form source file;
however, only one form at a time will be rendered on the mobile device.
The first form definition in your source file is the initial form that will be
displayed on the mobile device. The syntax for the form control follows:
01 Mobile:Form runat=server
02 id="id-of-control "
03 StyleReference="StyleReference "
04 OnActivate="OnActivateHandler "
05 OnDeactivate="OnDeactivateHandler ">
The id attribute is used to create a unique identifier for the Form in the
source file. This is important because you can have many forms in a file, and
you will need to reference each form for navigational purposes if nothing
else. The StyleReference attribute is used to apply a style sheet to any controls
inside the Form elements. More on this attribute in the "Presentation
Controls" section later in this chapter. The OnActivate and OnDeactivate
attributes are used to call a function after these events happen.The
OnActivate event occurs when the form is first displayed, and the
OnDeactivate event occurs when the form is replaced by another form.
An example of the Form control with an OnActivate event handler is
defined in Listing 16.2....