Microsoft Cloud Authors: Elizabeth White, Yeshim Deniz, Serafima Al, Janakiram MSV, John Katrick

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.

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
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
The standardization of container runtimes and images has sparked the creation of an almost overwhelming number of new open source projects that build on and otherwise work with these specifications. Of course, there's Kubernetes, which orchestrates and manages collections of containers. It was one of the first and best-known examples of projects that make containers truly useful for production use. However, more recently, the container ecosystem has truly exploded. A service mesh like Istio addr...
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO 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 over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
With 10 simultaneous tracks, keynotes, general sessions and targeted breakout classes, @CloudEXPO and DXWorldEXPO are two of the most important technology events of the year. Since its launch over eight years ago, @CloudEXPO and DXWorldEXPO have presented a rock star faculty as well as showcased hundreds of sponsors and exhibitors! In this blog post, we provide 7 tips on how, as part of our world-class faculty, you can deliver one of the most popular sessions at our events. But before reading...
DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
DXWorldEXPO LLC announced today that ICOHOLDER named "Media Sponsor" of Miami Blockchain Event by FinTechEXPO. ICOHOLDER give you detailed information and help the community to invest in the trusty projects. Miami Blockchain Event by FinTechEXPO has opened its Call for Papers. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Miami Blockchain Event by FinTechEXPO also offers s...
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
The IoT Will Grow: In what might be the most obvious prediction of the decade, the IoT will continue to expand next year, with more and more devices coming online every single day. What isn’t so obvious about this prediction: where that growth will occur. The retail, healthcare, and industrial/supply chain industries will likely see the greatest growth. Forrester Research has predicted the IoT will become “the backbone” of customer value as it continues to grow. It is no surprise that retail is ...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
DXWorldEXPO LLC announced today that "Miami Blockchain Event by FinTechEXPO" has announced that its Call for Papers is now open. The two-day event will present 20 top Blockchain experts. All speaking inquiries which covers the following information can be submitted by email to [email protected] Financial enterprises in New York City, London, Singapore, and other world financial capitals are embracing a new generation of smart, automated FinTech that eliminates many cumbersome, slow, and expe...
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...