SlideShare une entreprise Scribd logo
1  sur  26
   Handheld devices and mobile phones all now
    include Internet browsers

   ASP.NET developers need to be able to use their
    skill to create mobile versions of key enterprise
    applications.

   This chapter presents mobile Web applications to
    build Web applications that need to be displayed on
    compact screens across a vast array of devices
You will learn how to :

   Use the mobile web controls built into ASP.NET

   Set up an emulator. Emulators display the mobile
    Web application as it would appear on the hardware
    device.

   Create a mobile application that can be rendered on
    a variety of devices.
   Mobile Web controls were first introduced in
    ASP.NET 1.0.

   These controls used to be known as the Microsoft
    Mobile Internet Toolkit.

   They are now referred to as ASP.NET Mobile and
    consist of the mobile Web controls that ship with
    ASP.NET inside System.Web.UI.MobileControls and
    the features exposed by System.Web.Mobile.
   Starting with ASP.NET 2.0, the mobile Web controls were
    updated to allow the controls to use a new adapter-based
    architecture.

   These were device-specific adapter files.

   Then they started moving to a broader, standards-driven
    approach focused on markup-compliant rendering of
    HTML, Compact HTML (cHTML), Wireless Markup
    Language (WML), and Extensible Hypertext Markup
    Language (XHTML).

   This helps ensure support for different browsers on these
    devices.
   Early .NET Framework versions had built-in support for
    mobile Web applications.

   There were application templates for mobile Web
    applications and item templates for mobile Web forms,
    mobile Web user controls, and more.

   This allowed to build mobile Web applications using a
    designer, toolbox and design-time layout support.

   They are missing from Visual Studio 2008.

   Instead, you use the standard ASP.NET templates and
    modify them accordingly.
   A mobile Web application has a similar
    programming model to that of any ASP.NET Web
    site.

   To start creating a mobile Web application, you
    simply create an ASP.NET Web site.

   You can even mix mobile pages with non mobile
    pages.
   Like standard Web forms, the mobile Web form is an
    .aspx page that is accessible by a Uniform Resource
    Locator (URL) and can optionally have a code-behind
    page.

   The difference is that a mobile Web form inherits from
    System.Web.UI.MobileControls.MobilePage instead of
    System.Web.UI.Page.

public partial class Default : System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
   Next, you register the MobileControls namespace and
    assembly with your page.

   Doing so will give you IntelliSense access to the mobile
    controls inside Source view for your Web page.

   The following markup should be added to your page
    after the @ Page directive to accomplish this:

    <%@ Register TagPrefix="mobile"
    Namespace="System.Web.UI.MobileControls"
    Assembly="System.Web.Mobile" %>
   The last step is to replace the markup with mobile-
    like markup.
   This means adding a <mobile:Form> control to the
    <body> tag.

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <body>
    <mobile:Form id="Form1" runat="server">
    </mobile:Form>
    </body>
    </html>

   Visual Studio 2008 does not provide designer
    support for mobile forms.
   Unlike the standard Web form that can only contain one
    form declaration, the mobile Web form can contain many
    <mobile:Form> controls.

   The <mobile:Form> control is actually a group or container
    for other mobile controls.

   The <mobile:Form> control is of the type MobileControls.Form.

   You can switch from one <mobile:Form> to another by setting
    the ActiveForm property of the mobile Web form in code.
   You add mobile controls to a mobile form through
    markup. There is no real Toolbox support.

   However, if you have the MobileControls namespace
    registered, you will get IntelliSense support in Source
    view.

   There are a number of mobile controls you can add to a
    page.

   Controls added to a mobile Web form must all have a
    unique ID regardless of their form grouping.

   If you have two <mobile:TextBox> controls on a page, for
    example, you must give them unique ID values even if they
    are in different form controls
   You can view a mobile Web form using a Web browser.

   Many of the mobile device manufacturers provide
    emulators that can be used to test mobile Web
    applications.

   Emulators display the mobile Web application as it
    would appear on the hardware device.
   There are multiple device emulators out there.

   You can find a list of some of the more common ones at
    http://www.asp.net/mobile/device-simulators/.

   One of the more common cell phone emulator providers
    is OpenWave

   You can download the latest phone emulators from
    http://developer.openwave.com.

   OpenWave also provides skins for many popular
    phones.
   The Microsoft device emulator installs with Microsoft
    Visual Studio
   To access the emulator, in Visual Studio, from the Tools
    menu, select Device Emulator Manager.
   Here you can see the emulators that are installed.
   You can also select an emulator, right-click it, and select
    Connect to launch it.
   There are basic controls for user input such as Calendar,
    TextBox, Image, Label, Command (button-like behavior), and
    List.

   There are also a set of validation controls that work in a
    manner similar to those used by regular Web forms.

   In addition to control familiarity, developers should
    expect a similar event model.

   The mobile controls each provide Init, Load, Prerender,
    and Unload events. There are also control specific events
    such as OnClick for Command.

   You intercept these events in your code-behind file for
    any server-side event. The data-binding techniques are
    similar, too.
   Many mobile devices, such as most cell phones, don’t
    accept cookies.

   This causes problems with maintaining session state.

    The solution is to enable cookieless sessions.

   Add the following to the Web.config file inside the
    system.web element:

    <sessionState cookieless="true" />
    <mobileControls
    cookielessDataDictionaryType="System.Web.Mobile.CookielessData"
    />
   A mobile form with many controls can be displayed broken
    apart, so it’s important to focus on grouping controls that
    should be kept together.


   Pagination : Pagination is disabled by default but can be
    enabled by setting the Paginate property of each mobile form
    control to true. Pagination is best suited for mobile form
    controls that display lots of read-only data to keep a device
    from running out of memory.


   Panels : Panels are container controls that can be used to
    provide further grouping of controls for the purpose of
    enabling, disabling, hiding, and showing controls as a single
    group
   Styles can be used to change the visual
    appearance of a control.

   Implement styles by using the StyleSheet control
    or by using the <style> tag.

   Only one StyleSheet control can be assigned to a
    mobile Web form.

   When assigning styles, you can assign them
    directly to a property of the control, or assign
    the StyleReference property to a control.
   Adaptive rendering is the act of rendering a control
    differently based on the browser that requested the Web
    page. For example a mobile Calendar control is placed on a
    mobile Web form, displayed differently on a cell phone or
    a SmartPhone as shown below.
   When a browser requests a Web page, it sends an HTTP
    header called the User-Agent, which is a string that is used
    to identify the browser.

   The runtime uses the User-Agent string to look up the
    browser’s capabilities. The capability settings for each
    browser can be viewed and set in the browserCaps element
    in the config files.

   In ASP.NET, browserCaps relies on XML files that contain a
    hierarchal structure of browser definitions. The default
    location of the XML files is as follows:

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIGBrowsers
   Each of the XML files has a .browser extension; these files are
    used to build a class called HttpBrowserCapabilities, which is a
    factory class that creates an instance of HttpBrowser-Capabilities
    and populates its properties based on the browser type.


   You can modify the existing .browser files and create new
    .browser files. The HttpBrowserCapabilities class is in an
    assembly called ASP.BrowserCapsFactory.dll that is installed in
    the global assembly cache.



   To regenerate the ASP.BrowserCapsFactory.dll assembly and its
    HttpBrowserCapabilities class based on changes to the .browser
    files, run the aspnet_regbrowsers command-line tool in the
    .NET Command Prompt window using the –i switch (install).
   Device-specific rendering is the ability to specify rendering for a
    control based on a device type.
   One way to use device-specific rendering is to query the various
    Request.Browser properties and perform actions based on the
    browser type.


    public partial class LabelTest :
    System.Web.UI.MobileControls.MobilePage
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (Request.Browser.IsMobileDevice)
    {
    Label1.Text = "A mobile device";
    }
    else
    {
    Label1.Text = "Not a mobile device";
    }}}
   Another way to perform device-specific rendering is to use
    the DeviceSpecific control.

   A single DeviceSpecific control can be nested inside any
    mobile control or in the <mobile:Form> element to provide
    custom behavior based on a filter.

   A filter simply identifies a device.

   You add entries in the Web.config file for your site to define
    filters.

   Once configured, you can then use the filter as a choice
    inside the DeviceSpecific control.

   If the control to be rendered has a DeviceSpecific filter, the
    filter gets applied before the response is sent back to the
    device.
   Provide a separate desktop presentation
   Keep page content as simple as possible
   Instead of sending a complete result set to the user, only
    send the data record that the user is interested in.
   Test adaptive controls with several devices
   Present the user with default values whenever possible.
   Evaluate ViewState
   Use caching
   Combine many forms on a page
   Use cookieless sessions
   Using hyperlinks to a form
   Minimize image usage

Contenu connexe

Tendances

01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
Niit Care
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Niit Care
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
Niit Care
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobile
Flavius-Radu Demian
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
Niit Care
 

Tendances (20)

Advanced java lab swing mvc awt
Advanced java lab swing mvc awtAdvanced java lab swing mvc awt
Advanced java lab swing mvc awt
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
Firebase. Предмет и область применения — Тимур Ахметгареев
Firebase. Предмет и область применения — Тимур АхметгареевFirebase. Предмет и область применения — Тимур Ахметгареев
Firebase. Предмет и область применения — Тимур Ахметгареев
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
 
20140424 Android / iOS 개발자를 위한 Microsoft BaaS 세미나
20140424 Android / iOS 개발자를 위한 Microsoft BaaS 세미나20140424 Android / iOS 개발자를 위한 Microsoft BaaS 세미나
20140424 Android / iOS 개발자를 위한 Microsoft BaaS 세미나
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
How to use data binding in android
How to use data binding in androidHow to use data binding in android
How to use data binding in android
 
Introduction to jsf 2
Introduction to jsf 2Introduction to jsf 2
Introduction to jsf 2
 
Integrating into Visual Studio settings
Integrating into Visual Studio settingsIntegrating into Visual Studio settings
Integrating into Visual Studio settings
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Building a chat app with windows azure mobile
Building a chat app with windows azure mobileBuilding a chat app with windows azure mobile
Building a chat app with windows azure mobile
 
Revised Adf security in a project centric environment
Revised Adf security in a project centric environmentRevised Adf security in a project centric environment
Revised Adf security in a project centric environment
 
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & MenusLearn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
Learn Xamarin Absolute Beginners - Permissions, Building the App GUI & Menus
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
 
Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010Claims-Based Identity in SharePoint 2010
Claims-Based Identity in SharePoint 2010
 
uMobile Preconference Seminar
uMobile Preconference SeminaruMobile Preconference Seminar
uMobile Preconference Seminar
 
API & Custom Widgets coming in XCC next - Web Content and Custom App Extensio...
API & Custom Widgets coming in XCC next - Web Content and Custom App Extensio...API & Custom Widgets coming in XCC next - Web Content and Custom App Extensio...
API & Custom Widgets coming in XCC next - Web Content and Custom App Extensio...
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
 
Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02Selectionwidgetwhitepaper 140907120000-phpapp02
Selectionwidgetwhitepaper 140907120000-phpapp02
 

En vedette

Deploying configuring caching
Deploying configuring cachingDeploying configuring caching
Deploying configuring caching
aspnet123
 
Introducing asp
Introducing aspIntroducing asp
Introducing asp
aspnet123
 
User controls
User controlsUser controls
User controls
aspnet123
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
aspnet123
 
Programming web application
Programming web applicationProgramming web application
Programming web application
aspnet123
 
Custom controls
Custom controlsCustom controls
Custom controls
aspnet123
 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
aspnet123
 
ความรู้เกี่ยวกับอินเทอร์เน็ตบี
ความรู้เกี่ยวกับอินเทอร์เน็ตบีความรู้เกี่ยวกับอินเทอร์เน็ตบี
ความรู้เกี่ยวกับอินเทอร์เน็ตบี
Pheeranan Thetkham
 

En vedette (9)

Deploying configuring caching
Deploying configuring cachingDeploying configuring caching
Deploying configuring caching
 
Introducing asp
Introducing aspIntroducing asp
Introducing asp
 
User controls
User controlsUser controls
User controls
 
Globalization and accessibility
Globalization and accessibilityGlobalization and accessibility
Globalization and accessibility
 
Profile
ProfileProfile
Profile
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Custom controls
Custom controlsCustom controls
Custom controls
 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
 
ความรู้เกี่ยวกับอินเทอร์เน็ตบี
ความรู้เกี่ยวกับอินเทอร์เน็ตบีความรู้เกี่ยวกับอินเทอร์เน็ตบี
ความรู้เกี่ยวกับอินเทอร์เน็ตบี
 

Similaire à Mobile application

10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
Niit Care
 
Sybase sup hybrid_web_container_article_wp
Sybase sup hybrid_web_container_article_wpSybase sup hybrid_web_container_article_wp
Sybase sup hybrid_web_container_article_wp
Prabhakar Manthena
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer
home
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
harkesh singh
 

Similaire à Mobile application (20)

Web tech
Web techWeb tech
Web tech
 
Web techh
Web techhWeb techh
Web techh
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
 
Single Page Application
Single Page ApplicationSingle Page Application
Single Page Application
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Sybase sup hybrid_web_container_article_wp
Sybase sup hybrid_web_container_article_wpSybase sup hybrid_web_container_article_wp
Sybase sup hybrid_web_container_article_wp
 
Android Tutorial
Android TutorialAndroid Tutorial
Android Tutorial
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer
 
MVC 4
MVC 4MVC 4
MVC 4
 
A report on mvc using the information
A report on mvc using the informationA report on mvc using the information
A report on mvc using the information
 
Angular JS Basics
Angular JS BasicsAngular JS Basics
Angular JS Basics
 
Palm WebOS Overview
Palm WebOS OverviewPalm WebOS Overview
Palm WebOS Overview
 
Adobe Flex Introduction
Adobe Flex IntroductionAdobe Flex Introduction
Adobe Flex Introduction
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
 
MVC
MVCMVC
MVC
 
Asp
AspAsp
Asp
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Mobile application

  • 1.
  • 2. Handheld devices and mobile phones all now include Internet browsers  ASP.NET developers need to be able to use their skill to create mobile versions of key enterprise applications.  This chapter presents mobile Web applications to build Web applications that need to be displayed on compact screens across a vast array of devices
  • 3. You will learn how to :  Use the mobile web controls built into ASP.NET  Set up an emulator. Emulators display the mobile Web application as it would appear on the hardware device.  Create a mobile application that can be rendered on a variety of devices.
  • 4. Mobile Web controls were first introduced in ASP.NET 1.0.  These controls used to be known as the Microsoft Mobile Internet Toolkit.  They are now referred to as ASP.NET Mobile and consist of the mobile Web controls that ship with ASP.NET inside System.Web.UI.MobileControls and the features exposed by System.Web.Mobile.
  • 5. Starting with ASP.NET 2.0, the mobile Web controls were updated to allow the controls to use a new adapter-based architecture.  These were device-specific adapter files.  Then they started moving to a broader, standards-driven approach focused on markup-compliant rendering of HTML, Compact HTML (cHTML), Wireless Markup Language (WML), and Extensible Hypertext Markup Language (XHTML).  This helps ensure support for different browsers on these devices.
  • 6. Early .NET Framework versions had built-in support for mobile Web applications.  There were application templates for mobile Web applications and item templates for mobile Web forms, mobile Web user controls, and more.  This allowed to build mobile Web applications using a designer, toolbox and design-time layout support.  They are missing from Visual Studio 2008.  Instead, you use the standard ASP.NET templates and modify them accordingly.
  • 7. A mobile Web application has a similar programming model to that of any ASP.NET Web site.  To start creating a mobile Web application, you simply create an ASP.NET Web site.  You can even mix mobile pages with non mobile pages.
  • 8. Like standard Web forms, the mobile Web form is an .aspx page that is accessible by a Uniform Resource Locator (URL) and can optionally have a code-behind page.  The difference is that a mobile Web form inherits from System.Web.UI.MobileControls.MobilePage instead of System.Web.UI.Page. public partial class Default : System.Web.UI.MobileControls.MobilePage { protected void Page_Load(object sender, EventArgs e) { } }
  • 9. Next, you register the MobileControls namespace and assembly with your page.  Doing so will give you IntelliSense access to the mobile controls inside Source view for your Web page.  The following markup should be added to your page after the @ Page directive to accomplish this: <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
  • 10. The last step is to replace the markup with mobile- like markup.  This means adding a <mobile:Form> control to the <body> tag. <html xmlns="http://www.w3.org/1999/xhtml" > <body> <mobile:Form id="Form1" runat="server"> </mobile:Form> </body> </html>  Visual Studio 2008 does not provide designer support for mobile forms.
  • 11. Unlike the standard Web form that can only contain one form declaration, the mobile Web form can contain many <mobile:Form> controls.  The <mobile:Form> control is actually a group or container for other mobile controls.  The <mobile:Form> control is of the type MobileControls.Form.  You can switch from one <mobile:Form> to another by setting the ActiveForm property of the mobile Web form in code.
  • 12. You add mobile controls to a mobile form through markup. There is no real Toolbox support.  However, if you have the MobileControls namespace registered, you will get IntelliSense support in Source view.  There are a number of mobile controls you can add to a page.  Controls added to a mobile Web form must all have a unique ID regardless of their form grouping.  If you have two <mobile:TextBox> controls on a page, for example, you must give them unique ID values even if they are in different form controls
  • 13. You can view a mobile Web form using a Web browser.  Many of the mobile device manufacturers provide emulators that can be used to test mobile Web applications.  Emulators display the mobile Web application as it would appear on the hardware device.
  • 14. There are multiple device emulators out there.  You can find a list of some of the more common ones at http://www.asp.net/mobile/device-simulators/.  One of the more common cell phone emulator providers is OpenWave  You can download the latest phone emulators from http://developer.openwave.com.  OpenWave also provides skins for many popular phones.
  • 15. The Microsoft device emulator installs with Microsoft Visual Studio  To access the emulator, in Visual Studio, from the Tools menu, select Device Emulator Manager.  Here you can see the emulators that are installed.
  • 16. You can also select an emulator, right-click it, and select Connect to launch it.
  • 17. There are basic controls for user input such as Calendar, TextBox, Image, Label, Command (button-like behavior), and List.  There are also a set of validation controls that work in a manner similar to those used by regular Web forms.  In addition to control familiarity, developers should expect a similar event model.  The mobile controls each provide Init, Load, Prerender, and Unload events. There are also control specific events such as OnClick for Command.  You intercept these events in your code-behind file for any server-side event. The data-binding techniques are similar, too.
  • 18. Many mobile devices, such as most cell phones, don’t accept cookies.  This causes problems with maintaining session state.  The solution is to enable cookieless sessions.  Add the following to the Web.config file inside the system.web element: <sessionState cookieless="true" /> <mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData" />
  • 19. A mobile form with many controls can be displayed broken apart, so it’s important to focus on grouping controls that should be kept together.  Pagination : Pagination is disabled by default but can be enabled by setting the Paginate property of each mobile form control to true. Pagination is best suited for mobile form controls that display lots of read-only data to keep a device from running out of memory.  Panels : Panels are container controls that can be used to provide further grouping of controls for the purpose of enabling, disabling, hiding, and showing controls as a single group
  • 20. Styles can be used to change the visual appearance of a control.  Implement styles by using the StyleSheet control or by using the <style> tag.  Only one StyleSheet control can be assigned to a mobile Web form.  When assigning styles, you can assign them directly to a property of the control, or assign the StyleReference property to a control.
  • 21. Adaptive rendering is the act of rendering a control differently based on the browser that requested the Web page. For example a mobile Calendar control is placed on a mobile Web form, displayed differently on a cell phone or a SmartPhone as shown below.
  • 22. When a browser requests a Web page, it sends an HTTP header called the User-Agent, which is a string that is used to identify the browser.  The runtime uses the User-Agent string to look up the browser’s capabilities. The capability settings for each browser can be viewed and set in the browserCaps element in the config files.  In ASP.NET, browserCaps relies on XML files that contain a hierarchal structure of browser definitions. The default location of the XML files is as follows: C:WINDOWSMicrosoft.NETFrameworkv2.0.50727CONFIGBrowsers
  • 23. Each of the XML files has a .browser extension; these files are used to build a class called HttpBrowserCapabilities, which is a factory class that creates an instance of HttpBrowser-Capabilities and populates its properties based on the browser type.  You can modify the existing .browser files and create new .browser files. The HttpBrowserCapabilities class is in an assembly called ASP.BrowserCapsFactory.dll that is installed in the global assembly cache.  To regenerate the ASP.BrowserCapsFactory.dll assembly and its HttpBrowserCapabilities class based on changes to the .browser files, run the aspnet_regbrowsers command-line tool in the .NET Command Prompt window using the –i switch (install).
  • 24. Device-specific rendering is the ability to specify rendering for a control based on a device type.  One way to use device-specific rendering is to query the various Request.Browser properties and perform actions based on the browser type. public partial class LabelTest : System.Web.UI.MobileControls.MobilePage { protected void Page_Load(object sender, EventArgs e) { if (Request.Browser.IsMobileDevice) { Label1.Text = "A mobile device"; } else { Label1.Text = "Not a mobile device"; }}}
  • 25. Another way to perform device-specific rendering is to use the DeviceSpecific control.  A single DeviceSpecific control can be nested inside any mobile control or in the <mobile:Form> element to provide custom behavior based on a filter.  A filter simply identifies a device.  You add entries in the Web.config file for your site to define filters.  Once configured, you can then use the filter as a choice inside the DeviceSpecific control.  If the control to be rendered has a DeviceSpecific filter, the filter gets applied before the response is sent back to the device.
  • 26. Provide a separate desktop presentation  Keep page content as simple as possible  Instead of sending a complete result set to the user, only send the data record that the user is interested in.  Test adaptive controls with several devices  Present the user with default values whenever possible.  Evaluate ViewState  Use caching  Combine many forms on a page  Use cookieless sessions  Using hyperlinks to a form  Minimize image usage