ASP network programming: Creating a Mobile Web application

Source: Internet
Author: User

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 mobile devices will be endless. We can send data to users at any time and place. Typical mobile applications are developed on the server using WML, WMLScript, and Wbmp.

For dynamic WML applications, developers can use ASP, JSP, PHP, and so on. Mobile devices include cellular phones, pagers, palm-in-the-middle browsers, Pocket PCs, and car PCs. Few of these devices support WML, a few support HTML, and a smaller number support both WML and HTML. If you want to make sure that your application can be used on most mobile devices, you must create the application in WML and with limited HTML.

Recently Microsoft has proposed a revolutionary application development platform-.net Framework. The. NET framework includes ASP (the next version of ASP) for Web development. ASP. NET-based Web development supports traditional Web clients such as IE and Netscape, and supports mobile clients such as phone.com, Nokia cellular phones, and Pocket PCs. Asp. NET applications can be developed under 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 going any further, I'd like to give you a brief introduction to. NET. NET is a developing development platform presented by Microsoft at the 2000 Professional Developers Conference. The following diagram shows a simple structure for. NET Framework application development.

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

Conditions necessary for development

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

1. Windows professional/server/advanced Server OS

2. Internet Explorer 5.5

3.. 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 the mobile Web name Domain (System.Mobile.UI) provided by the. NET Mobile Web SDK (via the MobileUI.DLL file). For those who are unfamiliar with the term namespace (domain name), 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 an ASP. NET page

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

3. Designing pages with mobile controls

It's that simple.

Mobile controls

The mobile control is a block designed for developing mobile applications. For those who prefer to use an integrated development environment (IDE) such as VB and FrontPage to develop Gui/web, the Mobile control is similar to the HTML button control and the VB Grid control. Mobile controls simplify the process of developing programs by providing the functionality that programmers need.

For example, if you want to draw a WML card tag, you can use the mobile form control. The corresponding mobile control is provided for all WML tags. The attraction of Mobile controls is that they are not limited to WML tags, but rather they go beyond the WML tag to 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 an ASP.

〈%@ 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〉 

Incremental-Understanding ASP.

1. In the first line, the mobile Web name domain is inherited from the ASP. If you do not do this, ASP. NET will follow the normal Web application's page handlers.

2. In the second line, a token prefix is registered for the mobile Web name domain. You can see that in the rest of the code, the keyword "Moblie" is used as the name domain prefix for all mobile controls. You can use any name you want as a marker 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 the mobile form marker

Run the above example to see the results.

The above is an example of the effect shown in the Phone.com simulator. Now let's take a look at the code generated by asp:

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

Let's take a look at what happens 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, the Mobile control has the ability to detect the browser being used and generate the supported code. So, when you open an ASP. NET page in the WAP simulator, you get the WML code. You get HTML code when you open it in a Pocket PC. This gives us the ability to develop a service for any mobile device. 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

The mobile control can be divided into three main groups. They are user interface (UI) controls, validation (Validation) controls, and feature (Utility) controls. A user interface control is a set of controls that allows a user to control the user interface as a lable control. Validation controls allow us to validate user input such as RequiredFieldValidator controls, which validate user-entered data before sending data to the server. Feature controls are controls such as the Calendar control.

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

UI controls

Control Name Description Command a command control to perform an action such as commit information the Formform control is a container for one or more mobile controls the image is displayed in a mobile device label displays the output text in a mobile device link in a form creates a hyperlink list in a mobile device Show a list of options MobilePage control all mobile controls container textbox displays a single line of text box TextView a text box that displays multiple lines

validation controls

Control Name Description CompareValidator compare two mobile controls CustomValidator a custom inspector allows you to invoke your own inspection process from within the control RangeValidator the Limit inspector detects data in one scope regularexpressionvalid Ator detects data that does not match the expression specified by the control RequiredFieldValidator detects data entered by the user in this area ValidationSummary displays a report of all occurrences of the inspection process

Feature Controls

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

Automatic paging is one of the benefits of the. NET Mobile Web SDK. NET will handle page display problems for target devices. Different paging forms are taken for different mobile controls. For example, for a list control, pagination is handled by the control's PageSize property. This property is set automatically based on 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 is displayed 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)
' Move 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=server〉
〈mobile:label Runat=server〉your name:〈/mobile:label〉
〈mobile:textbox runat= "Server" id= "YourName"/〉
〈mobile:command runat= "Server" id= "btn" onclick= "Btn_onclick" 〉ok
〈/mobile:form〉
〈mobile:form id= "Frm2" runat=server〉
〈mobile:label runat= "Server" id= "Enteredname"/〉
〈/mobile:form〉
In the code above, two forms are created. The first form has an ID of Frm1, and the first form is idfrm2. This method is used because the mobile form control does not support the Name property, and the id attribute is supported. Asp. NET runtime is the way to confirm the form. In the first form, you add a lable control, a TextBox control, and a button control. The server-side VB subroutine (Btn_onclick) is called when the button is clicked. For those who are familiar with VB, it is as homely as at home. In the event of processing the VB subroutine, jump to the next form by setting the ActiveForm method to Frm2. Then access defines the lable control in Frm2 and sets the user-submitted value.

The following is the display screen of the above code in the Phone.com simulator and pocket IE Simulator:

The following is the code generated by ASP. NET for the Phone.com simulator:

As you can see, the WML Code of ASP. NET generates the text input of the user and sends 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. Do not need to detect browser and send WML or HTML based on target device

2. To learn only the ASP. NET mobile controls without having to learn WML

3. Visual Studio.NET easy-to-use programming mode drag-and-drop application development

4. Support server-side event handling

5. Support Automatic Paging

Limit:

1. Only available in Microsoft products and operating systems

2. When a new version of WML or HTML is released, you only wait for Microsoft to announce its release of the 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:

Embedded Microsoft Pocket Internet Explorer 4.5 's Pocket PC

Mitsubishi T250 Mobile Phone

Nokia 7110 Mobile

Nokia 7110 Nokia WAP Toolkit 2.0 Beta Emulator

The. NET Mobile Web SDK has had limited testing in preparation for the following:

Samsung Contact Mobile Phone

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 have not been tested under the conditions of the. NET Mobile Web SDK.

Summarize

The performance of the. NET mobile Web SDK and how the net mobile Web SDK supports different devices are shown in this article. You also see an example of building a mobile application using the. NET Mobile Web SDK. Want to get more about. NET Mobile Web SDK, please see the links below for more information about the treatment of impotence hospital Shanghai

ASP network programming: Creating a Mobile Web application

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.