C#
  Home arrow C# arrow Page 3 - Introduction to the Microsoft Mobile Inter...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

Introduction to the Microsoft Mobile Internet Toolkit
By: Jean-Baptiste Minchelli
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2002-05-06

    Table of Contents:
  • Introduction to the Microsoft Mobile Internet Toolkit
  • Architecture
  • Your first application
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Introduction to the Microsoft Mobile Internet Toolkit - Your first application


    (Page 3 of 4 )

    Before speaking about the MMIT and his functionalities, we will create the typical "hello world" application.

    Here it is the source code for our example:

    <%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="VB" %>
    <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"%>
    <mobile:Form runat="server">
    <mobile:Label runat="server" Text="Hello World!"/>
    </mobile:Form>


    Create a file with a .aspx extension in the Mobilequickstart virtual directory and navigate to it. Here is the result in my WAP browser:

    The result with the OpenWave browser

    Notice how the Web Server generated WML? If you access the URL with another browser, then you will receive the most appropriate language type. For instance, here's the code generated (HTML) for Internet Explorer 6.0:

    <html><body>
    <form id="_ctl0" name="_ctl0" method="post" action="test.aspx?__ufps=897416">
    <input type="hidden" name="__EVENTTARGET" value="">
    <input type="hidden" name="__EVENTARGUMENT" value="">
    <script language=javascript><!--
    function __doPostBack(target, argument){
    var theform = document._ctl0
    theform.__EVENTTARGET.value = target
    theform.__EVENTARGUMENT.value = argument
    theform.submit()
    }
    // -->
    </script>
    Hello World!</form></body></html>


    The server controls render the appropriate markup-language from the same code. MMIT currently supports the most common device types using cHTML, WML 1.1 and HTML 3.2. As we saw previously, this is possible with the machine.config file. The client device type is matched against the file and its capabilities are automatically associated with it.

    Please note that you have two ways to fill those properties:
    • machine.config file: this file is accurate for all the servers (and all the applications running on the server).
    • web.config: this file is valid just for the application. You can extend or change properties for supported device types.
    Extract of the machine.config file:

    <!-- OpenWave Browsers --><case match="(UP\.Browser)|(UP/)">
    browser = "Phone.com"
    inputType = "telephoneKeypad"
    canInitiateVoiceCall = "true"
    canSendMail = "false"
    cookies = "true"
    preferredRenderingType = "wml11"
    preferredRenderingMime = "text/vnd.wap.wml"
    rendersWmlDoAcceptsInline = "false"
    rendersWmlSelectsAsMenuCards = "true"


    In my examples I did not change the machine.config / web.config files. The browsers I used (Openwave SDK and Internet Explorer) are already defined in the configuration file.

    Building a complete application
    In this section I will present more of a complete example using Mobile Web Forms. I will use C# as the programming language; of course I could have used Visual Basic .NET or any other .NET language also. Mobile Web Forms have the peculiarity to be able to generate several physical pages for a single page of code. I will use this feature in my example.

    Let's start from scratch for our application:
    • Create a new virtual directory under the default web site. You can use the wizard if you need to.
    • Set its properties to "Low Process" and "Script and Executable".
    • Copy the web.config file and the bin directory from the QuickStart directory into your applications directory.
    • Finally, create the default.aspx file with the following code:
    <%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="C#" %>
    <%@ Register TagPrefix="M" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
    <%-- Change the current form --%>
    <script runat="server">
    protected void OnChange(object Send, ListCommandEventArgs Dest)
    {
    if(Dest.ListItem.Value == "About")
    ActiveForm = About;
    else
    ActiveForm = Editorial;
    }
    </script>
    <%-- Stylesheet --%>
    <M:Stylesheet runat="server">
    <Style name="Title" Font-Size="Large"/>
    </M:Stylesheet>
    <%-- Index form --%>
    <M:Form id="Index" runat="server">
    <M:Image runat="server" ImageURL="servauto.gif" AlternateText="ServAuto.org">
    <DeviceSpecific>
    <Choice Filter="IsWML" ImageURL="servauto_wap.wbmp" />
    </DeviceSpecific>
    </M:Image>
    <M:List id="ListIndex" runat="server" Decoration="Bulleted" OnItemCommand="OnChange">
    <Item Text="Editorial" Value="Editorial" />
    <Item Text="Aims" Value="About" />
    </M:List>
    </M:Form>
    <%-- About form --%>
    <M:Form id="About" runat="server">
    <M:Label Text="The two aims of ServAuto are" runat="server" StyleReference="Title"/>
    <M:List Wrapping="NoWrap" id="ListAbout" runat="server" Decoration="Bulleted">
    <Item Text="Develop a free car-sharing service." />
    <Item Text="Build and maintain a directory reserved of motorcar website."/>
    </M:List>
    </M:Form>
    <%-- Editorial form --%>
    <M:Form id="Editorial" runat="server" Paginate="true">
    <M:Label Text="What is ServAuto.org" runat="server" StyleReference="Title"/>
    <M:Label Text="ServAuto is a non profit organization founded in March 2000." runat="server" />
    <M:TextView runat="server">
    Blablabla blabla ...
    </M:TextView>
    </M:Form>


    In our example we have three Mobile Forms:
    • The index.
    • The editorial.
    • General Information.
    Your first form will be called when the page is loaded. It uses the list control that will call the "Onchange" method. This method just changes the current form. We added a picture to this form. It will be displayed respectively to the device capabilities. The second form is very similar to the first one.

    Our third form will display the editorial. With the value "True" for the "Paginate" attribute, we allow the web server to paginate content according to the device capabilities (screen size, file size, etc):

    Paginating in action

    Notice that the text has been cut? The link allows you to navigate to the second page of the article.

    Here's how it looked in Internet Explorer 6.0:

    Result in I.E. 6.0

    Here's how it looked with the OpenWave SDK:

    Result with OpenWave SDK

    We see that the picture shown in Internet Explorer is a colored GIF. In our WAP browser, it is a monochrome bitmap.

    Here's the source code sent to the WAP browser:

    <?xml version='1.0'?>
    <!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML1.1//EN' 'http://www.wapforum.org/DTD/wml_1.1.xml'><wml><head>
    <meta http-equiv="Cache-Control" content="max-age=0" />
    </head>
    <card>
    <p><img src="/myapp/(wbaew1bclbaclvzhryydqj55)/servauto_wap.wbmp" alt="ServAuto.org" /><do type="accept" label="Go"><go href="mos_pbc2"><setvar name="mcsvt" value="ListIndex"/><setvar name="mcsva" value="$(ListIndex)"/></go></do><select name="ListIndex"><option value="0">Editorial</option><option value="1">Aims</option></select></p></card>
    <card id="__pbc2">
    <onevent type="onenterforward"><go href="/myapp/(wbaew1bclbaclvzhryydqj55)/my.aspx" method="post"><postfield name="__VIEWSTATE" value="aDxfX1A7QDw73LjnjJDtsrzgo4QsMDs+Oz4=" /><postfield name="__EVENTTARGET" value="$(mcsvt)" /><postfield name="__EVENTARGUMENT" value="$(mcsva)" /></go></onevent>
    <onevent type="onenterbackward"><prev /></onevent>
    </card>
    </wml>

    More C# Articles
    More By Jean-Baptiste Minchelli


     

    C# ARTICLES

    - Introduction to Objects and Classes in C#, P...
    - Visual C#.NET, Part 1: Introduction to Progr...
    - C# - An Introduction
    - Hotmail Exposed: Access Hotmail using C#
    - Razor Sharp C#
    - Introduction to Objects and Classes in C#
    - Making Your Code CLS Compliant
    - Programming with MySQL and .NET Technologies
    - Socket Programming in C# - Part II
    - Socket Programming in C# - Part I
    - Creational Patterns in C#
    - Type Conversions
    - Creating Custom Delegates and Events in C#
    - Inheritance and Polymorphism
    - Understanding Properties in C#






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT