Using the Control in your Application
Add a reference to the control assembly by right clicking the "ASP.NET Mobile Controls" project, choose Add Reference, select the Projects tab, select the "DirectMobileClassLibrary," and click OK. Next open the "MobileWebForm1.aspx" page. The blank ASP.NET mobile form comes up. Select the HTML view at the bottom to view the HTML associated with this ASP.NET page. You need to register the control on the page by adding the following code at the top of the file "MobileWebForm1.aspx."
<%@ Register TagPrefix="myControl" Namespace="DirectMobileClassLibrary.myMobileControls"
ASP.NET mobile controls have a TagPrefix of mobile, however because you have a new control you need to specify the TagPrefix(any name), and provide the Namespace and Assembly in which the control resides. The TagPrefix would be used to pre-fix your control on the page. Next you need to place the actual control on the page within the form tag.
<mobile:form id="Form1" runat="server">
<myControl:MultiLineTextBox id="MultiLineTextBox1" runat="server"
Rows="3" Cols="20" Text="First Mobile Control"></myControl:MultiLineTextBox>
You can also set the controls properties by specifying the rows, cols, and text as shown above.
Testing the Application
Hit F5 to run the application. The MobileWebForm1.aspx page loads, the control within it loads, and the adapter code kicks in to render the control as a TextArea control in your default browser. If you load up the PocketPC emulator that comes with VS.NET 2003 and try the application, it works beautifully even there as the emulator supports HTML rendering.
The ASP.NET mobile environment and the rendering technology is the most extensible technology from the Redmond stable. You can easily build any kind of controls and adapters from scratch, as I've done in this article. And, there are options to extend existing controls and support new devices. As a best practice, always check if the existing controls within ASP.NET can be extended to support any new requirement you may have.
This same rendering and extensibility technology is going to be available in all the new .NET controls in Whidbey, thereby allowing you to peacefully use any control, knowing it will render automatically to any device and enabling you build/extend a control for multiple devices. And that is something big to look forward to.