Article

Home » Server-side Coding » ASP & .NET Tutorials » On the Road with .NET Mobile Controls

About the Author

Tiberius OsBurn

author_tiberius Tiberius is a .NET evangelist and author of many articles dealing with .NET in the 'real world'. Mr. OsBurn's Website can be found at http://tiberi.us

View all articles by Tiberius OsBurn...

On the Road with .NET Mobile Controls

By Tiberius OsBurn

January 28th, 2003

Reader Rating: 8

Page: 1 2 Next

Interested in .NET? Don't miss SitePoint's .NET Feature Guide -- it's an excellent resource!

Here's the scenario: your boss wants information on the go, but he hates to haul along his laptop. He's sick of the hassle of bringing it on airplanes and lugging it around. He wants a mobile application that provides him with the information he usually accesses on your extranet.

Now let's say the boss is on his way to a big meeting with one of our top suppliers in Boston. He tells you he wants you to design an application where he can pull up supplier information for each product that your company sells -- so all of the data is available to him while he's on the road... he needs it available on his cell phone and he needs it done by this Thursday.

1003_productDon't worry. When the boss whips out his Nokia to check on the suppliers of Boston Crab Meat, one of your top sellers, he's going to get all the supplier info we've got in the database. That includes the contact's name, title, and the company's address and phone number -- the boss is looking forward to a big crab dinner with this client and he has to know where to go and who to contact.

Much like the explosion of PC-based browsers in the 1990's, the penetration of Internet-enabled phones has skyrocketed in the last few years, leaving IT developers scrambling to provide information-hungry clients with the content they desire. Previously, you would have to hand code multiple mobile Web pages -- remaining aware of the many different protocols your clients may be connecting with and the different languages used by the client. This proved to be a nightmare for any understaffed IT department, as it meant not only keeping pages up to date, but also keeping a keen eye on the technological changes that happen in the infancy of the Internet telephony community.

Getting Started

1003_supplierFor this scenario, I installed the VS.NET Mobile Internet Toolkit and was finished with this code in under an hour -- all because of the amazing ease and integration of the .NET framework. The Mobile Internet Toolkit is a collection of controls that allow developers to create mobile applications that can connect and communicate with your Web server -- dishing up content onto your cell phone, PDA or other portable device. It's available as a free download from MSDN -- just search for the Microsoft Mobile Internet Toolkit.

I'm going to walk you through some of the features of using the Mobile Internet Toolkit, and then we'll build that application for the boss.

Before you begin, I suggest you go out onto the Web a get yourself a phone emulator. This will help you design a bit more realistically than will the view that VS.NET displays. The good folks at phone.com have been hard at work creating top-notch emulation software that allows you to mimic the many different phone browsers available. Before you release your mobile application to the world, you'll want to make sure that the functionality is what you expect -- and the best way to do this is with an emulator.

It's all .NET

The really cool thing about the Mobile toolkit is that it takes advantage of the .NET Framework. That means you can program software designed for your mobile devices in the same languages that you use when creating windows and Web applications. If you're familiar with how a Web or Windows application is created in Visual Studio .NET, you'll quickly pick up on creating mobile applications.

Once you've loaded the Mobile Toolkit, you'll create an ASP.NET project and add to it a Mobile Web form. Once you've defined a Mobile Web form, you can use it almost exactly like a regular Web form.

Getting There Fast

Creating an application so your boss can browse the company's supplier information is pretty easy to accomplish. We'll use the NorthWind database we're all so familiar with to illustrate how easy it is to get a mobile application up and running.

1003_explorerOne of the secrets for creatiile application is to break it down into its most simplistic parts. Remember, we're coding for a screen that fits into your pocket, so we need to follow one simple rule: Keep it Simple, Stupid.

Creating a mobile application is just as easy as creating a Web application, with a few differences. One key difference is that you'll be working with multiple forms on one mobile page. You can think of a collection of forms as a stack of cards that you can flip around and display on a mobile device. You could use only one form per page, but it's easiest to group two or three forms with related functionality on the same page. This will make your application more legible and cleaner -- it also helps reduce your code if you're passing information from form to form. You switch between forms by setting the ActiveForm property of the mobile page -- this allows you to push new information "to the surface" in your application.

Our main page, productsView.aspx, houses two forms: Product and SupplierInfo.

1003_multiformsBoth forms are simple -- containing only a single control per form. The Product form displays the many products we sell in a browsable list, the control we'll be using is the ObjectList. The SupplierInfo form displays all of the information we have on our supplier in the database -- we're using a TextView object. Here's the gist of how the application will work: the boss can select a particular product on one form and view the related information for the Supplier on another. When the boss selects a Product, the SupplierInfo form is activated and populated with all the information we have about that supplier. Pretty simple, eh?

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links