![]() |
|
Writing ASP applications for Pocket PCs
By Paul Adams, November 05, 2001.
IntroductionActive Server Pages (ASP) has provided an excellent environment for developers to rapidly create stable, feature rich, data driven applications. PocketASP brings this power the Pocket PC, enabling developers to apply their existing skills to an exciting new platform. This article explains how to get from installation through to creating a working PocketASP application. InstallationThe evaluation version of PocketASP is available from http://www.ModeZero.net/PocketASP. It is fully functional and not time limited. If machine space is available, it is recommended that the ADOCE 3.1 version be downloaded as that contains the most up-to-date ADO drivers. On The PC
On the Pocket PC
Now to test that the installation was successful:
Demonstration PagesAs a warm-up, before diving into creating your own pages, follow the link on the homepage to see the examples. Some of the key supported ASP objects and methods are demonstrated, such as:
Development EnvironmentThe PocketASP project enables ASP developers to create their web applications in the normal way (on a PC) and then adds a new final stage of copying the pages down to the Pocket PC when the development is complete. The caveat is to be aware of currently supported objects and methods, as described in the release notes. For example, persistent cookies are supported, but per-session cookies are not, which means using the Session object to store session-based information. While developing on the PC, it's possible to get an approximation of how the pages will look on the Pocket PC device. Using IE5, with View->Text Size set to Smallest, the following JavaScript creates a suitably sized window:
Hello World ExampleAn introduction to a platform would not be complete without a Hello World application. The example below was developed using Visual Interdev and tested on a machine running IIS, before being copied down to an iPaq H3630 for final testing. Here's a step-by-step guide to getting an ASP page up and running. 1. Write the ASP code
Below is an example of some over-engineered code to output a Hello World message. <%= sHello & " " & WorldFn %>
<% '--------------------------------------- function WorldFn() WorldFn = "World!" end function '--------------------------------------- %> 2. Test It on the PCPlace the Hello.asp file into a virtual directory under IIS. Lets call it FirstExamples. Navigating to http://MyMachine/FirstExamples/Hello.asp should result in a friendly Hello World! message appearing in your browser. 3. Create a new Pocket PC pseudo-domainThe installation process creates a directory called PAspPages in the root of the Pocket PC. The directories contained in \PAspPages are treated as pseudo-domains (for example ModeZero is created by the install for the demonstration pages). Note that, just like real domains, the pseudo-domain names should not contain spaces. We need to create a new directory (pseudo-domain) under \PAspPages for our Hello World example page. Again, we'll use FirstExamples. 4. Copy to Pocket PCUse Explorer to find the recently created /PAspPages/FirstExamples/ directory on the Pocket PC and copy Hello.asp from the PC to that directory. 5. Test it on the PocketPCTo see the finished product, open Pocket IE and type pasp://FirstExamples/Hello.asp. The same friendly message will appear on your browser. The Hello World example shows that there are no tricks or hidden steps, the source files don't get mangled or transformed in any way (in fact, you could develop and edit them on the device). The only alteration that may be needed is to the look and feel of your pages to make allowances for the amount of screen space available. Database AccessIncluding database functionality in your Pocket PC application is, again, business as usual for the ASP developer. The database support is provided using ADOCE, which is a subset of ADO. The core functionality of ADO is provided, i.e. adding, updating and removing information from tables. Below are the steps to take to get your ASP application ready for database access:
For example: Connect to Pocket PC Database
Open a Recordset
(taken from the DemoDB.asp sample page) Sessions And CookiesIf your application needs to store per-session or cross-session information then the Session and Cookie objects and methods are available and function in the usual way. The cookies use the pseudo-domain described above to define their scope, for example cookies in the ModeZero domain cannot be accessed from the FirstExamples domain. Releasing Your ApplicationFinally, when it comes to releasing your application, developing in ASP means you are free from the current headache of compiling and maintaining versions over the different flavours of Pocket PC processor. The same code will run on all supported PocketASP platforms, making development and testing times shorter and source control simpler. SummaryBy using their existing skills, ASP developers can quickly create exciting new applications across the Pocket PC platforms. The database synchronisation features already provided by ActiveSync 3.1, coupled with the database support in PocketASP, enable access to a wealth of new data driven Pocket PC application opportunities. For many Pocket PC applications, developing in ASP will be quicker, more stable and easier to rollout than using the traditional alternatives. ResourcesInformation on PocketASP can be found at http://www.ModeZero.net/PocketASP. There is also a discussion group on Yahoo! at http://groups.yahoo.com/group/PocketASP. Related resources:DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||