Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Developing Mobile Applications Using the Microsoft Mobile Internet Toolkit : Page 4

It's easy to get started building cross-platform mobile applications using the Mobile Internet Toolkit. This tutorial will take you step by step through a simple application that you can deploy today on ASP.NET.


advertisement
Performing the SQL Lookup
Figure 10. Populating Form4: Use a List control to display the results of the SQL query.
When the user clicks on the Search button, we will formulate the SQL statement, retrieve the results, and display them in Form4. For simplicity I am creating the SQL statements directly—beware of SQL injections. (See Listing 1 for the code in VB.NET and Listing 2 for C#.)

In Form4, I used a List control to display the results returned from the SQL query. I need to do some configuration for the List control to make it look like the finished output in Figure 10.

Figure 11. Displaying Form4 in Pocket IE: By setting the ItemsPerPage property to three, only three of seven results are displayed at once. The full result set is paginated.
Set the Decoration property to Numbered, so that items will display with a serial number. Set the ItemsPerPage property to whatever number you wish. I set it to three so that, at most, three items will be shown on the screen. You also need to set the Paginate property of Form4 to true, so that the List control can paginate its list in multiple pages (see Figure 11 and 12).

Figure 12. Displaying Form4 in UP.Simulator: By setting the ItemsPerPage property to three, only three of seven results are displayed at once. The full result set is paginated, though, unlike in Pocket IE, the numbering restarts at one on each page.
To ensure that the items in the List control are clickable, you need to service the ItemCommand event of the List control. When an item is clicked, we will display the next form, which is Form5 (see Figure 13.)



Figure 13. Populating Form5: Form 5 is where the user finally gets the phone number he/she requested.
The Image control in Form5 can be customized to display different image formats depending on the type of device that is viewing the page. The PhoneCall control allows devices (such as cell phones) that support making phone calls to directly call a number. For devices that do not support this feature, it will display text.
Figure 14. Display Form5 on Pocket IE and UP.Simulator: finished employee record can be seen here in both of our test environments.
When the user clicks on an item on the List control, it will display the photo of that person (the image name is the EmployeeID and stored in the current working Web directory). Other employee information is also retrieved from the database. Listing 3 shows the code to activate Form5 in VB.NET; Listing 4 shows the same in C#.

If you click on the email link on the Pocket IE, you can directly send an email using Inbox. On the UP.Simulator, you can select the "Phone:" entry and make a call (on a real phone you would be able to make a call directly).

That's it! Using the MMIT is pretty similar to programming ASP.NET. The only difference is that one of the devices that is actually accessing the application. As a mobile application developer, you need to ensure (with a lot of testing) that your application runs correctly on all devices that it is designed for.



Wei-Meng Lee is a Microsoft .NET MVP and co-founder of Active Developer, a technology company specializing in hands-on training on the latest technologies. He is an established developer and trainer specializing in .NET and wireless technologies. He speaks and writes frequently on topics ranging from .NET to Mac OS X. He is the author of "Windows XP Unwired" (OReilly & Associates) and is currently working on "Programming the .NET Compact Framework," also from OReilly. He can be reached at weimeng@activedevelop.com.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap