Creating a mobile Web application

Source: Internet
Author: User
Tags include visual studio

Introduced

Nowadays mobile devices have become a part of our lives, and many of us are inseparable from them. When these mobile devices are connected to the Internet, the power of the mobile device will be endless. We can send the data to the user at any time and place. Typical mobile applications are developed using WML, WMLScript, and wbmp on the server.

For dynamic WML applications, developers can use ASP, JSP, PHP, and so on. Mobile devices include cellular phones, pagers, palm browsers, Pocket PCs and on-board PCs. A handful of these devices support WML, few support HTML, and a few support WML and HTML at the same time. If you want to make sure that your application is available on most mobile devices, you must create the application in WML and limited HTML.

Microsoft recently presented a revolutionary application development platform-.net Framework. The. NET framework includes the ASP.net (next version of ASP) for Web development. asp.net Web development supports traditional Web clients such as IE and Netscape, as well as mobile clients such as phone.com, Nokia cellular phones and Pocket PCs. Asp. NET applications can be developed in any. NET-supported language environment such as vb.net (next version of VB), JScript, C + +, C #, and so on. In this article, we'll see how to use the. NET Mobile Web SDK, ASP. NET and VB. NET view mobile application.

. NET Introduction

Before I go any further, I'd like to give you a brief introduction to. NET. NET is a development platform developed by Microsoft at the 2000 Professional Developer Conference. The following diagram shows the simple structure of the. NET Framework application development.

When a asp.net page request is sent from a Web client such as IE or a mobile device, IIS collects the request and passes it to the. NET Framework. If the ASP.net page is the first request, the. NET framework will compile the asp.net into an intermediate language (intermediate Language,il). The IL code is then compiled by the Just-in-time (just-in-time,jit) compiler for the cost code. As you can see, the. NET Framework is the core of the entire ASP.net application. The. NET Framework will provide the necessary resources and the language compiler you have chosen because of the compiled code.

Necessary conditions for development

To use. NET to develop mobile applications, you must download and install the following components. IE and the. NET SDK can be downloaded free of charge from the Microsoft MSDN site .

1. Windows professional/server/advanced Server OS

2. Internet Explorer 5.5

3. The. NET Framework Beta 1

4.. NET Mobile Web SDK Beta 1

5. WAP Simulator

Let's get started!

To use. NET to develop mobile applications, you must include a mobile Web name Domain (System.Mobile.UI) that is provided by the. NET Mobile Web SDK (via MobileUI.DLL files). For those who are unfamiliar with the term namespace (name domain), the name domain is like a C + + header file and a reference to Visual Basic. The name domain will provide the classes required to develop the application.

It is easy to develop mobile applications using the. NET framework.

1. Create a asp.net page

2. Include Mobile Web Namespace--system.mobile.ui

3. Design the page with mobile control

It's so simple.

Mobile controls

A mobile control is a program block designed to develop mobile applications. For those who prefer to use an integrated development environment (IDE) like VB and FrontPage to develop Gui/web, Mobile controls resemble HTML button controls and VB Grid controls. Mobile controls simplify the process of developing programs by providing the functionality required by the programmer.

For example, if you want to draw a WML card tag, you can use the mobile form control. The corresponding mobile controls are available for all WML tags. The interesting thing about Mobile controls is that they are not limited to WML tags; instead, they go beyond WML tags and create useful mobile controls, such as Calendar mobile controls that cannot be implemented in WML.

Let's take a look at a show "Hello world!" Example of a ASP.net page.

〈%@ Page inherits= "System.Mobile.UI.MobilePage"
〈%@ Register tagprefix= "Mobile" namespace= "System.Mobile.UI"
〈mobile:form runat= "Server"
〈mobile:label runat= "Server" 〉hello, world!〈/mobile:label〉
〈/mobile:form〉

Step-by-Step-understanding asp.net pages

1. In the first line, the mobile Web name domain is inherited for the ASP.net page object. If this is not done, ASP. NET will follow the page handlers for ordinary Web applications.

2. In the second line, a tag prefix is registered for the mobile Web name domain. You can see in the rest of the code that all mobile controls use the keyword "Moblie" as the name domain prefix. You can use any name you want as a tag prefix.

3. In the third line, create a mobile form and set its Runat property to server.

4. In line fourth, create a mobile label control and "Hello World" text.

5. Last line, close mobile form marker

Run the above example and watch the results.

These are examples of the effects shown in the Phone.com simulator. Now let's take a look at the code generated by asp.net:

Isn't it cool? Asp. NET generates code for us, the mobile form control has been converted to a WML card tag, and, similarly, the Mobile label control is converted to a WML paragraph tag.

Let's take a look at what's going on in pocket ie:

Let's take a look at the code generated by ASP.net for pocket ie:

〈html〉
〈body〉
〈form id="ctrl1" name="ctrl1" method="post" action="Exp1.Aspx?631169274439268880"〉
〈div〉Hello, World!〈/div〉
〈/form〉
〈/body〉
〈/html〉

Asp. NET generates HTML code for pocket ie. Indeed, Mobile controls have the ability to detect the browsers they use and generate the supported code. So, when you open a ASP.net page in the WAP simulator, you get the WML code. And you get HTML code when you open it in your Pocket PC. This will give us the ability to service any mobile device at once. It's cool, isn't it?

Mobile Application Design Concepts

The NET Mobile Web SDK provides three container objects: MobilePage, Form, and panel. The MobilePage control is an important container for mobile applications. A single mobilepage can have one or more form controls. A form control can have 0 or more panel controls. The Panel control is used to group various mobile controls.

mobile controls in the. NET Mobile Web SDK

Mobile controls can be grouped into three primary groups. They are user interface (UI) controls, Validation (Validation) controls, and functionality (Utility) controls. User interface controls are a set of controls that allow users to control the user interface as lable controls. Validation controls allow us to validate user input such as the RequiredFieldValidator control, which validates the data entered by the user before sending data to the server. A feature control is a control such as a calendar control.

The following table shows the controls for each of these categories.

UI controls

Control Name Description Command a command control executes actions such as submit information Formform control is container image of one or more mobile controls display image label in mobile devices display output text in a form link create a hyperlink list in a mobile device Show a list of options MobilePage control the container textbox for all mobile controls a text box showing a single line textview a text box showing multiple lines

validation controls

Control Name Description CompareValidator compares two mobile controls CustomValidator custom inspectors allow you to call your own inspection process from within a control RangeValidator limit checker to detect data in a range regularexpressionvalid Ator detects data that is not in conformity with the expression specified by the control RequiredFieldValidator detects the data entered by the user in this area ValidationSummary displays a report of all occurrences of the validation process

Feature Controls

Control Name Description Call dial a phone number calendar display a calendar AdRotator randomly display an ad

Automatic paging is one of the advantages of the. NET Mobile Web SDK. NET will handle the problem of the page display of the target device. Different mobile controls take different forms of paging. For example, for a list control, pagination is handled by the control's PageSize property. This property is automatically set according to the target device. When the page is displayed at run time, the controls in the Panel control stay together.

A simple example

Let's write a simple application that displays a text box that accepts input and displays it in the next form.

〈%@ Page inherits= "System.Mobile.UI.MobilePage"%〉
〈%@ Register tagprefix= "Mobile" namespace= " System.Mobile.UI "%〉
〈script language=" VB "runat=" Server "
Sub Btn_onclick (Src as Object, E as EventArgs)
' mov E to the next mobile form
ActiveForm = Frm2
' Display the name.
Enteredname.text = "Your name is:" & yourname.text
End Sub
〈/script〉
〈mobile:form id= "Frm1" Runat=ser ver〉
〈mobile:label runat=server〉your name:〈/mobile:label〉
〈mobile:textbox runat= "Server" id= "YourName"/〉
〈mobile:command runat= "Server" id= "btn" 〉ok
〈/mobile:form〉
〈mobile:form id= "Frm2" runat=server〉
〈mobile: Label runat= "Server" id= "Enteredname"/〉
〈/mobile:form〉
In the above code, two forms were created. The ID of the first form is Frm1, and the first form's idfrm2. This method is used because the mobile form control does not support the Name property and supports the id attribute. Asp. NET runtime is the way to confirm the form. In the first form, you added a lable control, a TextBox control, and a button control. When the button is clicked, the server-side VB subroutine (Btn_onclick) is invoked. This is for those who are familiar with VB, like at home as cordial. In events that handle VB subroutines, you can skip to the next form by setting the ActiveForm method for Frm2. Then access defines the lable control in Frm2 and sets the user-committed value.

The following are the screen screens in the Phone.com Simulator and pocket IE Simulator:

The following is the code generated by ASP.net for the Phone.com emulator:

As you can see, ASP.net generates the WML code of the white powder to process the user's text input and send it to the server side. It also generates WML code to display the user-entered name in the next WML card.

Advantages and limitations of the. NET Mobile Web SDK

Here are some of the advantages and limitations of using the Mobile Web SDK.

Advantage:

1. No need to detect browsers and send WML or HTML based on target devices

2. Learn only asp.net and. NET mobile controls without having to learn WML

3. Visual Studio.NET application Development for drag-and-drop in Easy-to-use programming mode

4. Support server-side event handling

5. Support Automatic Paging

Limit:

1. Only used in Microsoft products and operating systems

2. When a new version of WML or HTML is released, you are only waiting for Microsoft to announce its release of its new mobile Web control

Supported devices

. NET Framework is still under development. Currently, the. NET Mobile Web SDK has been fully tested in the following devices:

Pocket PC with embedded Microsoft Pocket Internet Explorer 4.5

Mitsubishi T250 Mobile Phone

Nokia 7110 Mobile Phones

Nokia 7110 Nokia WAP Toolkit 2.0 Beta Simulator

The. NET Mobile WEB SDK has limited testing in the following preparations:

Samsung Contact Mobile

Sony CMD-Z5 Mobile Phone

Microsoft Mobile Explorer v 2.01 simulator

L phone.com up. SDK 4.0 Simulator

Phone.com up. SDK 3.2 for WML emulator

There are many other support devices, but they are not tested under the. NET Mobile Web SDK condition.

Summarize

This article shows the performance of the. NET mobile Web SDK and how the net mobile Web SDK supports different devices. You also see an example of using the. NET Mobile Web SDK to build a mobile application. Want to get more about. NET Mobile Web SDK, check out the relevant links below.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.