Welcome!

Microsoft Cloud Authors: Janakiram MSV, Yeshim Deniz, David H Deans, Andreas Grabner, Stackify Blog

Related Topics: Microsoft Cloud

Microsoft Cloud: Article

Leveraging the List Controls in the Mobile Internet Toolkit

Leveraging the List Controls in the Mobile Internet Toolkit

Microsoft's Mobile Internet Toolkit represents one of the best ways available today to create Web-based applications that target multiple kinds of mobile devices, including:

  • Pocket PCs
  • WAP phones
  • Palm OS PDAs
  • i-Mode phones
The best thing about this technology, however, is that it doesn't require you to create multiple applications in order to target all of these. Instead, it provides you with a single, abstract set of server-side components with which to create a single .NET Web application that can adapt to any of these devices.

Some of the most powerful, yet least understood, of all the components in the Mobile Internet Toolkit are the various "list" objects. Of these, the first and simplest is simply known as the List control. A slightly more complex form of this control is the SelectionList. The absolute pinnacle of both power and difficulty-of-use, however, is the ObjectList control. In this article, I will give you a brief overview of the proper use of all three of these components.

The List List
As I mentioned above, the List control is the simplest of all the list components. In order to see it in action, simply drag it from the control palette onto any blank Form inside of any Mobile Web Page.

If you already know all of the items that you would like to have listed within this component, then you can set them all to this point using the Visual Studio Properties window. Within this window, there is an Items property. If you click this property, you will see a dialog like the one in Figure 1.

To add items to the list using this interface, simply click the "Create New Item" button. Next, fill in the "Item Text" field, then the corresponding "Item Value" field. The difference between these two values is simple: the values in "Item Text" will actually be displayed to users of your Web application, whereas the values in "Item Value" are what will actually be sent to your code when one of these items is selected.

To see an example of this, enter the names of several different Web sites as the "Text" values in your List control. For each of these Web sites, enter their URL as their "Value." For example, you might enter the Text of "SYS-CON Media homepage" and the Value of http://www.sys-con.com.

Before running your application, make sure that you have also set the List's ItemsAsLinks property to true. Now when you run your application you will see that all of the Text properties you entered are displayed on the Web page as hyperlinks. If you follow any of these hyperlinks, however, you will be taken to the URL specified in the associated Value property!

Rendering its Items as hyperlinks is the greatest degree of interactivity supported by the List control. It is intended principally for displaying output in an ordered fashion to a remote browser. There is, therefore, no way for the control to communicate back to your application once it has been rendered on the remote browser.

The SelectionList List
For situations in which a greater degree of interactivity is required or desired, the SelectionList is one of just two options provided to you by the base Mobile Internet Toolkit distribution. The other option, as we will see momentarily, is the ObjectList control. The SelectionList is not quite as powerful as the ObjectList, but it is much easier to use.

To see the SelectionList in action, first delete your existing List component, then drag a SelectionList from the palette and drop it onto the place where your List used to be. Notice that there is an Items collection for this list component just like there was for the first List control. Go ahead and add a few Text/Value pairs.

Notice that there is one feature on this dialog that was not on the dialog for the standard List control - the checkbox labeled "Selected." It is there because, unlike on the standard List control, items on the SelectionList may or may not be selected at any given point in time. In its default format, you can check this checkbox for as many items as you like.

When you close the Items dialog, you will see that the SelectionList is now displaying the first selected item that you have entered. If you did not select any items, then it is simply displaying whatever the first item is that you entered. Scroll up to the SelectType property and try all of the various settings underneath this property (see Table 1).

In Table 1, the first column (left to right) gives you the name of the SelectType option, as shown in the Properties dialog. The second column tells you the maximum number of items that will be displayed on the screen at a single time. For two of these - the Listbox and the MultiSelectListBox - this number is controlled by the Rows property, which is also visible in the Properties dialog.

Exclusive versus nonexclusive selectivity will determine whether or not you can choose multiple items using a given SelectList control. If you want to do this, you must set the SelectType for your SelectList to either MultiSelectListBox or Checkbox, because none of the other SelectTypes support this.

At this point, you should go ahead and add a Label and a Command control to your Mobile Web Form so that it looks like Figure 2. Double-click the SelectionList and enter the code shown in Listing 1. The SelectedIndex property will tell you the index of the first item that is selected in any SelectionList. Our code uses this property as an index into the SelectionList's Items collection so we can retrieve the Value of the first selected item.

If you run your Mobile Web application project now, you will see that when you select an item, nothing happens. However, when you click the button, a round-trip to the server is triggered and the Label text is populated with the value of the first selected item. This raises two interesting questions. First, how can we retrieve the Values of all the items selected, rather than just the first one - in case we are using one of the two SelectTypes in which multiple items can be chosen? Second, how can we avoid having to click the command button in order to trigger a round-trip to the server?

One approach to solving the first problem is shown in Listing 2. This code iterates through all of the items in a given SelectionList, checking the Selected property of each one. If this property is true, then it knows that the item has been selected and it concatenates its value to the end of the Caption string. At the end of the code, the entire caption string is pasted into the Label control.

The ObjectList List
Unfortunately, resolving our second issue is quite a bit more complicated. In order to do this, we will need to upgrade to the ObjectList control - which is by far the most complicated of the List controls. For our efforts, however, we will also be rewarded with the greatest degree of flexibility.

To begin with, the only way to get items into an ObjectList is to bind the ObjectList with a data source. You can verify this for yourself by deleting the Label, Command, and SelectionList from your existing Mobile Web Form and dragging an ObjectList onto the Mobile Web Form to replace them. If you examine the Properties window for this control, you will see that there is no Items property - therefore, there is no way to add items through the Properties window.

The good news is that, unlike all of the other List controls, this control supports multiple fields. This means that if you want to list many pieces of information for each item, you should always choose the ObjectList control. For example, whereas with the List or SelectionList controls you could display only the names of all your employees, with the ObjectList, you could display their names, ages, salaries, and Social Security numbers all at once!

In order to bind the ObjectList to a data source, you must first have a data source. This should be something that is accessible via ADO.NET, the new technology for accessing data using .NET. Examples of data that can be accessed via ADO.NET include:

  • SQL Server
  • Oracle
  • OLE DB data sources
  • ODBC data sources
You'll notice that the last two items are, in themselves, capable of providing connectivity to an even wider array of data sources. This is because there are, in fact, ADO.NET Managed Providers for providing legacy support for both of these older technologies.

Once you have a data source, you need to tell the ObjectList how to connect to it and what data it should use from it. You can do this by manipulating the properties described in Table 2.

The last two rows in Table 2 are of particular interest because they tell us something about the functionality of the ObjectList, which is quite different from either of the previous lists. When an ObjectList is first displayed, it presents a simple list composed of a single field, just like any of the other lists. This is the field denoted by the LabelField property and should be a unique identifier for all of the items in your ObjectList. If you were displaying data about employees, for example, you might choose their names for this display, or their Social Security numbers.

In this display, all of the items are links. In an HTML or cHTML browser, this would usually mean that they were all hyperlinks. On a WAP phone, it would probably mean that they were all items in a menu. Regardless of the form factor, they would all generate round-trips to the server immediately upon selection - unlike either of the two previous lists.

Once the server received the selection, it would present a second view of the data that "punched down" onto additional data about the chosen record. The fields in this view would be pulled from the TableFields property.

In addition to being able to display multiple data fields, the ObjectList is also alone in its ability to accept "commands" associated with each data item. This is possible via the Commands collection of the control, the Properties dialog for which is illustrated in Figure 3.

To add commands, simply click the "Create New Command" button and then enter your desired command names and texts. At runtime, the texts for each of your commands will be displayed as selectable commands on the punch-down view for each item.

In order to react to each of the commands, however, you will have to write some custom code. Listing 3 shows a general example of the kind of code that you will have to write. By double-clicking the ObjectList, you can bring up the ItemCommand event handler and note that it is passed an ObjectListCommandEventArgs object. This object has a number of useful properties, but here we use the CommandName property to determine which of the commands has been selected. The exact action you will want to perform will depend entirely upon the exact nature of your application and commands.

Conclusion
I hope that you have found this discussion of the various Lists available in the Mobile Internet Toolkit useful. If you have any questions, you know where to find me - [email protected]!

More Stories By Derek Ferguson

Derek Ferguson, founding editor and editor-in-chief of .Net Developer's Journal, is a noted technology expert and former Microsoft MVP.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering m...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, discussed how they built...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
@DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...