The ASP.NET Mobile controls are formerly known as the Microsoft Mobile Internet Toolkit (MMIT). Mobile controls extend the power of the .NET Framework and Visual Studio to build Mobile Web applications.
The ASP.NET Mobile controls reduce the work required for developers to target a wide variety of browsers by eliminating the need to write and maintain numerous web applications each targeted to a specific browser.
The ASP.NET Mobile controls render the appropriate markup (HTML 3.2, WML 1.1, cHTML. XHTML) while dealing with different screen sizes, orientations and device capabilities.
Mobile Web Forms Controls:
Mobile Web Forms Controls generate markup language for different devices. These are ASP.NET server side controls that provide user interface elements such as:
- Image, etc.
The Mobile controls generate the correct markup for the device that makes the request at execution time. As a result, you can write a Mobile application once and access it from multiple devices.
Because these Mobile controls are based on the ASP.NET controls, you can leverage your current desktop development skill set when creating mobile applications.
You can also reuse the same business logic and data access code that you use in your desktop application. Mobile and desktop Web Forms can reside in the same Visual Studio .NET project. This makes an application faster to develop and lowers your maintenance cost.
Mobile Web forms controls are as follows:
Figure 1: Mobile Web Form Controls.
Creating Mobile Web Form Controls:
There are the following steps for creating the Mobile Web Form Controls.
Step 1: For creating a Mobile Web project open the new Web site in Microsoft visual studio 2005. You will get the following window.
Figure 2: Open New Website.
Step 2: After open the New Website, go to the Solution Explorer right click on the Website and click on Add New item then you will get the following window:
Figure 3: Add New Item in Solution Explorer.
Step 3: Add a mobile Web Forms page to the project. You will see the following code-
<%@ Control Language="VB" AutoEventWireup="true" CodeFile="WebUserControl.ascx.vb" Inherits="WebUserControl" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
Step 4: Drag a Mobile Web Forms control onto the form. Suppose we want to print Name and Address of any user in the Textbox. Then we drag two Textbox and two labels. Label is optional. The source code is as follows:
<%@ Control Language="VB" AutoEventWireup="true" CodeFile="WebUserControl2.ascx.vb"Inherits="WebUserControl2"%>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"Assembly="System.Web.Mobile" %>
<table cellpadding="0" cellspacing="0" border="2" height="50px" style="width: 33%">
<td align="center" valign="top" style="padding-top:20px;">
<mobile:Label ID="Label1" Runat="server" BackColor="Gold" Visible="False">User name</mobile:Label>
<mobile:TextBox ID="TextBox1" Runat="server" BackColor="#FFFFC0" Visible="False"></mobile:TextBox>
<mobile:Label ID="Label2" Runat="server" BackColor="Gold" Visible="False">Address</mobile:Label>
<mobile:TextBox ID="TextBox2" Runat="server" BackColor="#FFFFC0" Visible="False"></mobile:TextBox>
In the following figure two Labels and two Textbox are drag from the Mobile controls. So the design view of the source code is as follows:
Figure 4: Design view of the above source code.
Step 5: Double-click the control to write the logic.
Step 6: Rebuild the application.
Step 7: Run the application.
Mobile Internet Designer:
The Mobile Internet Designer extends the Visual Studio .NET IDE to create Mobile applications. After you install the Mobile Internet Designer, you can create and develop your Mobile application in the same way that you would develop a Windows Forms or Web Forms application.
The Mobile Internet Designer makes it fast and easy to build and maintain Mobile Web applications.
Device Capability Mechanism:
Accurate information about the display capabilities of the target device is essential for the successful rendering of Mobile controls. Mobile controls need the following information about a device:
- Markup language (HTML, WML, cHTML)
- Number of display lines
- Cookie support
- Screen size
The Mobile Internet Toolkit adds these mobile device capabilities to the server's machine.config file (desktop ASP.NET applications use this file to maintain device and browser information).
Advanced Features: Extensibility
Device adapter includes in the Mobile Internet Toolkit for a variety of mobile devices.
Through the device capabilities mechanism The Mobile Internet Toolkit supports device adapters for additional devices. You can create new aggregate controls from existing Mobile controls.
The Mobile Internet Toolkit provides the technology and tools to build, deploy, and maintain sophisticated Mobile applications quickly. Additional device support can be added using the Mobile Internet Toolkit's extensibility features.