Advertisment

Mobile Development on .NET

author-image
PCQ Bureau
New Update

The Microsoft.Net platform and Visual Studio.Net 2003 provide a comprehensive suite of tools suited for mobile applications development. It offers a gamut of devices whether one is targeting, the Pocket PC, a mobile web phone/device user (Sony, Nokia, Siemens, phones or Palm type devices) or targeting the new breed of SmartPhones or Tablet PC.

Advertisment

This article covers building applications targeting either various devices (phones and internet capable devices) and Pocket PC

devices. It also includes information on how you could build applications for the SmartPhone or Tablet PC platforms.

Choosing the new project template as ASP.Net Mobile Web application

Microsoft’s Visual Studio.Net 2003 IDE (Integrated Development Platform) is all that you would need to get up and running with both Internet enabled devices as well as Pocket PC devices. 

Advertisment

There are essentially two types of mobile applications which a user can develop

Connected/Online applications and Disconnected/Offline applications. The very names connote the kind of applications and the devices which can be targeted. 

Connected apps



Most mobile phones today come with a browser of some kind and provide WAP access. This enables one to build applications much like Internet applications where the user can view your applications at a particular URL.

Advertisment

Disconnected apps



When we look at devices such as the Pocket PC they are rich devices, providing local storage, as well as the ability to connect to the Internet. When building applications for such kind of devices one can take the analogy of a desktop application which when required accesses a web service on the Internet for further data exchange. This brings up very interesting possibilities as one can take advantage of the rich capabilities of the device, provide offline functionality and take advantage of the Internet connectivity when available.

ASP.NET Mobile Designer



ASP.NET Mobile Designer extends ASP.NET and the .NET Framework, allowing you to build Web applications for mobile phones, PDAs, and pagers. This designer is integrated into the Visual Studio IDE. You can create mobile Web applications, use the Mobile Designer to modify a mobile Web form, and then build and run the application, all from within Visual

Studio.Net. 

Building Mobile Web Applications
The Adaptive Rendering Process

Advertisment

The extensibility model in the ASP.Net mobile controls allows you to quickly add support for new devices to your applications. After adding additional device adapters, you can perform testing, update your server, and access your applications from new devices. Microsoft also offers device updates (allowing you to download the update), perform sanity testing, and update your servers

When you build a mobile ASP.Net application, you are actually creating a Website that targets mobile devices. All the code is running on the server and the device just behaves as a browser.

Let’s start by building an actual application for the mobile web space. Visual Studio.NET 2003 out of

the box supports building mobile ASP.NET applications

Advertisment

Choose WML11

from the available device filters drop down

Start Visual Studio.Net and choose a new project. Choose the project template as ASP.Net Mobile Web application. As shown in figure 1 above.

(Note: You could choose whichever programming language you are comfortable with VB.Net or C#). The IDE automatically creates the environment necessary for you to start building a mobile web application. A default form called

MobileWebForm1.ASPX is created for you. Drop a Label control on to the form and change it’s text property to ‘Hello World’. 

Advertisment

Press F5 key to compile the application and load it in the default web browser. Even though we’ve actually gone ahead and built a mobile Web application, it loads up in Internet Explorer. One needs a little bit of backgrounder to understand the process behind the scenes. 

ASP.Net Mobile Controls



All the controls that you use when building a mobile web application are ASP.NET mobile controls. ASP.NET mobile controls enable developers to target a wide range of mobile devices, including Web-enabled cell phones, pagers, and PDAs, such as the Pocket PC. ASP.NET provides the same rich Web application model for mobile devices as it does for ASP.NET applications that target desktop browsers. ASP.NET mobile controls consist of a set of ASP.NET server controls and device adapters that can intelligently render your application. 

Use Applied Device Filters Screen for

choosing device filters

Advertisment

It is recommended to download some other mobile emulators such as the Openwave emulators. URL’s for all such downloads are in the resources section at the bottom of the article.

It’s very evident that the programming model is similar to the ASP.NET web application development model.



You may argue that certain devices have certain inbuilt capabilities which one may want to exploit like for instance certain phones support the ability to make a call via clicking a certain URL for example, lets say there is a link for customer support on a wap
enabled site.

You might also want to display certain content to certain users depending on the device they are using. Well you will be more than happy to know that you can write device specific code as well as write code for applications supporting special features.

Device Specific Code



Writing device specific code is an easy task. Choose the earlier created MobileWebForm1.aspx file. Select the label control you placed earlier. Press F4 to access the property window. Scroll down the property window till you come to a section called Device Specific. Here select the Applied Device filters property. The following image as shown in Figure 3 is displayed. 

Changing the text to Hello there WAP users,

in the property overrides dialog box. 



The message “Hello there WAP user” displayed in the Openwave mobile simulator 

Next one needs to choose Device Filters from the Available Device Filters drop down list. Here we select two filters one for normal web browsers and the other for WAP browsers. Choose HTML32 from the drop down list and click the button ‘Add to List’.

Similarly from the same drop down choose WML11 and add to list.

After adding the filters for this specific label control click OK. 

To make the label control display different text depending on the browser.

Select the label control scroll to the Device Specfic section, Choose the ‘Property Overrides’ property. 

In the property overrides dialog box which pops up change the text property to ‘Hello there WAP user’as shown in Figure 5 below.

Similarly, select the ‘Applied Device Filter’ drop down in the same dialog box and choose ‘HTML32’ filter. Change the text property to ‘Hello there Internet Explorer’.

What we’ve just done is set two filters and set appropriate device specific actions.

Click OK to close the ‘Property Overrides’ dialog box. Once we’ve done the above it’s time to see our code in action. Right click the Mobile WebForm1.ASPX page in Solution explorer and choose ‘Browse With…’option. Select ‘Microsoft Internet Explorer’ and choose the ‘Browse’ button. This will open up Internet Explorer and browse your page. You will see the text “Hello there Internet Explorer” displayed in your browser window.

Now if you’ve checked the resources section and installed lets say the Openwave browser you can Right click the MobileWebForm1. ASPX page in Solution explorer and choose “Browse With…” option. This time select Openwave WAP browser. You will see the message “Hello there WAP user” displayed to you in the Openwave mobile phone simulator.

The ASP.Net mobile controls automatically format content based on the device. However, at the same time it provides you the flexibility to write your own device specific code. You must have noticed that we haven’t written a single line of code. 

We will cover the .NET Compact Framework in the next issue.

Sanjay Shetty, 



CEO, Wireless Strategist and Consultants and Microsoft MSDN Regional Director, Mumbai

Advertisment