Reader Level:
ARTICLE

Utility Controls - Mobile Internet

Posted by Puran Mehra Articles | Mobile & Embedded April 22, 2010
In this article I will explain you about Utility Controls in Mobile Internet.
  • 0
  • 0
  • 4215

This article has been excerpted from book "The Complete Visual C# Programmer's Guide" from the Authors of C# Corner.

We have covered the basics of user interface controls and validation controls. Now we move on to something even more interesting to a programmer. The basic utility controls provided by the Mobile Internet Toolkit reduce some of the pain of writing code and make the most out of what you write. There are three utility controls: Calendar, Call, and AdRotator.

Calendar

The Calendar control is the most powerful of the three utility controls. This class is similar to the Web.UI.Calendar class but provides a display of the day/week/month that is dependent on the physical screen capability of the device. This control provides the date selection functionality and displays the selected date.

Listing 24.8 shows an example in which the user is asked to select the date.

Listing 24.8: Example of Calendar Control


<%
@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="C#" %>
<%
@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>

<
script language="c#" runat="server">
    protected void Calendar_Selection(Object sender, EventArgs e)
    {
        Label1.Text = "The selected date is " + Calendar1.SelectedDate;
        ActiveForm = Form2;
    }

</
script>

<
mobile:form id="Form1" runat="server">
<
mobile:Calendar id="Calendar1"
OnSelectionChanged
="Calendar_Selection"
SelectionMode
="DayWeek"
runat
=server/>
</
mobile:form>
<
mobile:form id="Form2" runat="server">
<
mobile:Label id="Label1" runat="server"/>
</
mobile:form>

The code in Listing 24.8 generates the output shown in Figures 24.11 through 24.15 and gives you the opportunity to select the date, as the figures show. 

Figure-24.11.gif

Figure 24.11: Screen Prompting User to Select a Date

Figure-24.12.gif

Figure 24.12: Screen Prompting User to Select a Month

Figure-24.13.gif

Figure 24.13: Screen Prompting User to Select a Week


Figure-24.14.gif

Figure 24.14: Screen Prompting User to Select a Day

Figure-24.15.gif

Figure 24.15: Final Output Shown After Submit, Showing Date Selected by User

Call

The second utility we are going to look at is calling functionality. You must be thinking: What is so special about calling from a mobile phone? Yes, it is from this control that you can automatically call a displayed number. Let's suppose you want to call the company number that is embedded in your company address in the display. It would be nice if the number were activated when a user clicks on the link for the phone number. There is no need to remember the number anymore. The following code shows how this is done:


<
mobile:Call runat="server"
AlternateURL
="http://c-sharpcorner.com/"
phoneNumber
="9109845248004">
Shivani`s Creation

</
mobile:Call>

AdRotator


The final control we'll discuss is the AdRotator. This particular utility control is the same as Web.UI.WebControls.AdRotator. It picks an advertisement from the file specified in the AdvertisementFile property.

Here is what this control looks like:


<
mobile:AdRotator runat="server" AdvertisementFile="myAd.xml">
</
mobile:AdRotator>

If you are using images or want to provide personalization in the form of a message, you can use the DeviceSpecific control.

In this article we have covered the bits and bytes of the Mobile Internet Toolkit. These are the basics you need to know to start programming mobile devices in .NET. Now let's look at a couple of case studies.

Conclusion

Hope this article would have helped you in understanding Utility Controls - Mobile Internet. See other articles on the website on .NET and C#.

visual C-sharp.jpg The Complete Visual C# Programmer's Guide covers most of the major components that make up C# and the .net environment. The book is geared toward the intermediate programmer, but contains enough material to satisfy the advanced developer.

COMMENT USING

Trending up