Use mobile Web form in Visual Studio. NET to create a mobile network application

Source: Internet
Author: User


Use mobile Web form in Visual Studio. NET to create a mobile network application

In the past few years, the world has been seen as an explosion of new devices-including network phones and the Internet-making personal digital assistance possible-it ensures that it is the next-generation user of the software you created today. When this explosion develops to consumers or organizations, there can be a wide variety of device options, it requires developers to fight with devices and devices differently.

To help developers create applications for these new "thin customer" devices, Microsoft has released the mobile Internet Toolkit (originally.. NET mobile Web SDK) directly integrated into Visual Studio.. NET environment.

The new integrated toolkit and Visual Studio. NET combine to make it easy to create an application. It can intelligently adapt to different devices when obtaining only the advantages that belong to the device. Now you can create a mobile network application project in Visual Studio. NET and use the visualization designer to create and edit mobile Web pages. You can order Visual Studio. Net beta 2 or download the mobile Internet Toolkit from the msdn website.

The mobile Internet toolkit consists of a series of server-side mobile network forms and mobile Internet designer that creates user interfaces. It also includes the Quickstart wizard, development documentation, and device adapter source code.

Mobile web forms control extends the capabilities of ASP. NET and. Net frameworks to help developers create mobile network applications such as Pocket PCs for cellular phones and personal digital assistants. These controls use translations for different devices and generate the appropriate markup language: Wireless Markup Language (WML) Version 1.1, Hypertext Markup Language (HTML) version 3.2, or streamline HTML (chtml ).

In this article, you will learn the basic steps for creating a mobile network application. Before creating a mobile Web Forms Application, you must install Microsoft Visual Studio. Net beta 2 and mobile Internet Toolkit beta 2. With these technologies, you can immediately create mobile network applications for cell phones and Pocket PCs.

Mobile web forms Control
Microsoft mobile network form control is built on the. NET Framework. It brings the advantages of the ASP. NET network development model to the world of mobile applications. In addition, mobile network form control provides the following features:

  • Tool support worldwide:Fully supported from Visual Studio integrated development environment (IDE), using its rich toolbox and designer, drag-and-drop server control, automatic configuration, and many other features.
  • Supports a variety of devices:ASP. NET is used to target many mobile devices-from thin clients to XML-based mobile phones to HTML-based Pocket PCs.
  • Write a webpage at a time:Write a network application and configure it to any supported mobile service. You can use a series of mobile network form controls to write complex applications without knowledge of WML and other standard languages. The smart Server Control handles many implementation differences between browsers, devices, and the Internet.
  • Customization and scalability:Benefit from ASP. NET customization and expansion features. In addition, the scalability model will support other devices in the future. This ensures that future products of the convenience device support the mobile network applications you have compiled today.

Mobile web forms
Mobile web forms pages are designed for ASP. NET web forms pages. It is a text file with a. aspx extension, and it contains a set of mobile control-ASP. NET Server controls-it can adapt to the environment provided by supported mobile devices.


As a developer, you can use device-independent properties, methods, and events to arrange mobile pages and controls. When a supported device requires a mobile network form page, this page and control automatically determine the device and generate an environment suitable for the device's capabilities. For example, some devices can display more lines of text than other devices. Some devices can display images when other devices cannot, while some devices can place telephones rather than others.

Each mobile network form page must have the following standard header indication, which indicates that it is a mobile page. The language = attributes are various, depending on the language you use for your page.


<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="C#" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
  Assembly="System.Web.Mobile" %> 

Because a mobile network form page contains mobile control, each mobile control bar should include the runat = "server" attribute:

<mobile:Form runat="server"></mobile:Form>

Each page contains at least one mobile form that is marked by a tag. However, you can place multiple forms in a mobile network form page.

Just like other ASP. NET Server controls, mobile control can publish an object model containing attributes, methods, and events. You can use this object model to modify and access this page. The object model of mobile control is device independent, so you can interact with the control in a unified way, regardless of the target device.

Two methods for creating a mobile network form page
Network form programming imitates Microsoft Visual Basic developers to write traditional Microsoft Windows-based applications. To build a Windows Forms Application in Visual Basic, you add a form to the project and drag and drop a control to the form, set Properties and double-click Control to write the code running after the form. This well-known model is used by millions of developers to quickly build desktop applications. Mobile Network form technology brings the same design principles and production levels to mobile network applications.

To create a widely used mobile network application that uses mobile network forms, you can simply add a new mobile network form to your project and drag the control to the webpage, double-click Control to add the code running behind the page. You can select the language for implementing business logic for the mobile network forms page. Visual C #. net, Visual Basic. net, and Visual C ++ are included in Visual Studio. NET.

The following example demonstrates how to use Visual Studio. NET mobile Internet designer or mobile Internet Toolkit and command line to create a mobile network application (including in Microsoft mobile Internet Toolkit.

Visual Studio. NET mobile Internet designer
The following example uses Visual Basic. NET and calendar control to demonstrate how to process multiple forms defined in a mobile network form page. When a page is accessed by a customer for the first time, the page displayed for the first time is displayed by default. You can move to another form by setting the activeform attribute of the mobile page in a planned manner, or you can allow a user to transfer to a form by using Link Control. The following example demonstrates two forms of pages and an example of activeform navigation.

Create a twoformsapp
First, create a new directory named twoformsapp.

  1. Run Visual Studio. net beta 2 system requirements list, supports Internet Information Services (IIS) operating system non-product test computer to install Visual Studio. net beta 2 and mobile Internet Toolkit.
  2. Start Visual Studio. NET beta 2 from the File menu and select new project. In the new project dialog box, select Visual Basic projects from the project types list. In the templates list, select mobile Web application. Enter twoformsapp as the project name and click OK.


Figure 3. New Project dialog box

Create mobilewebform1.aspx user interface
By default, when you create your application, the mobile network form page calls mobilewebform1.aspx for display. This is a user interface file. Based on the capabilities of the customer device, it contains many server-side mobile control and HTML 3.2, chtml or WML 1.1 environments. Mobilewebform1.vb, a compiled background code file, will be created later to process your programming logic.

  1. From the mobile forms toolbar, drag a label, A Textbox, and a command button to form1.
  2. Click label in form1. Make sure that the Properties window is in the bottom right corner of your screen. Enter the date (mm/DD/YYYY) in the label1 text field ). This text is displayed in the label of the form.
  3. Change the text attribute for the command button to display form2.
  4. Drag an additional form to the design surface under form1. The new form is named form2. Add a command button and a calendar control. Change the text attribute of the command button to display form1.

During the design, the surface of your form should be shown in Figure 4.


Figure 4. Visual Studio. NET mobile Internet designer

Create mobilewebform1.aspx. VB background code file
Double-click show form2. A new file, mobilewebform1.aspx. VB, is opened. Your pointer will be in the public sub commandementclick. Add the following code:


Public Sub Command1_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Command1.Click
        Dim datetext As Date
        datetext = TextBox1.Text
        ActiveForm = Form2()
        Calendar1.SelectedDate = datetext
        Calendar1.VisibleDate = datetext
End Sub 

In the design view, double-click the show form1 button. Your pointer will be in public sub command2_click now. Add the following code:


Private Sub Command2_Click(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles Command2.Click
        Dim dateval As Date
        dateval = Calendar1.SelectedDate
        ActiveForm = Form1()
        TextBox1.Text = dateval
End Sub

Run the twoformsapp Application

  1. In Solution Explorer, right-click the mobilewebforms1.aspx file and select set as start page.
  2. Save your application, and then press F5 to create and debug it. Alternatively, select start form from the Debug menu.
  3. When the application is running, enter the date in a specific form, and then click show form1. Form2 appears, and the calendar control is displayed.
  4. To select a date, click calendar, and then click show form2.

To test applications that use mobile devices, your network service requires a fixed IP address.

Microsoft mobile Internet Toolkit and command line

Visual Studio. Net beta 2 directly integrates mobile Internet Toolkit into the development environment, making many designs, development, and debugging automated. However, mobile apps can also be manually created using your favorite editor, mobile Internet Toolkit, and command line compilation. The following example demonstrates how to use C # To Do This. It also demonstrates how to handle onclick events from Command Control. When the code receives this event, it navigating to another form by program. A new active form generates an onactivate event. You can control it to initialize the form.

Create nameapp

  1. Create the directory c:/inetpub/wwwroot/name on a non-product test computer running Windows 2000 Server or Windows 2000 Professional operating system with Service Pack 1.
  2. From Internet Services Manager, expand the default web site list, right-click name (Virtual root), and click Properties.
  3. Under application settings, click Create on the right of application name.

In the following example, you will create two files in the name directory.

  • Name. aspx is a user interface file. According to the customer's device, it contains a large number of server-side controls and environment translations of HTML 3.2, chtml or WML 1.1.
  • Name. CS is the background code file, which is a compiled C # component. The extension of this file varies according to the language used for writing it. If the part is a visual basic part, the file name is name. VB.

Create name. aspx mobile network form


<%@ Page Codebehind="Name.cs" Inherits="NameApp.NamePage" Language="C#" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls"
  Assembly="System.Web.Mobile" %>

<mobile:Form runat="server">
   <mobile:Label runat="server">What is your name?</mobile:Label>
   <mobile:Textbox runat="server" id="NameEdit"/>
   <mobile:Command runat="server" OnClick="GoCommand_OnClick" Text="Go!"/>
</mobile:Form>

<mobile:Form runat="server" id="SecondForm" OnActivate="SecondForm_OnActivate">
   <mobile:Label runat="server" id="Greeting"/>
</mobile:Form>

Create name. CS background code file


using System;
using System.Web.UI.MobileControls;

namespace NameApp
{
    public class NamePage : MobilePage
   {
      protected Form SecondForm;
      protected TextBox NameEdit;
      protected UI.Label Greeting;
      private String greetingText;

      protected void GoCommand_OnClick(Object sender, EventArgs e)
      {
         greetingText = "Hello, " + NameEdit.Text + "!";
         ActiveForm = SecondForm;
      }

      protected void SecondForm_OnActivate(Object sender, EventArgs e)
      {
         Greeting.Text = greetingText;
      }
   }
}

Compile the name. CS File

  1. Create a folder named extension in the name directory.
  2. Enter the following code in the command line to compile the name. CS file:
  3. C:/inetpub/wwwroot/Name> /R: system. web. dll/R: system. web. mobile. DLL _/Target: Library/out: Bin/nameapp. DLL name. CS

View http: // localhost/name. aspx and test the application on a PC, a Pocket PC, or any current test device listed below.

Device currently tested

  • Pocket PC
  • Sony CMD-z5 with Microsoft mobile Explorer
  • Mitsubishi t250
  • Nokia 7110
  • Sprint touchpoint
  • Samsung touchpoint
  • Simulator for Microsoft mobile Explorer version 2.01
  • Simulator for phone.com up 3.2
  • Simulator for Nokia 7110
  • Simulator for phone.com up 4.0
  • Personnel computer with Microsoft Internet Explorer 5.5

Conclusion
The next generation of Microsoft Visual Studio development tools significantly reduces the complexity of creating mobile network applications. Use Visual Studio.. NET page, develop applications for the network and in fact any mobile device-instead of learning a variety of sdks. It simplifies the creation of technologies that inherit the support for industrial standards for mobile network applications, such as Extensible Markup Language (XML) and Wireless Application Protocol (WAP ), microsoft will allow you to create next-generation mobile network applications.

Access mobile newsgroup to communicate with your peers about mobile network forms. Note that you can use any news reading software to access these news groups. However, we recommend that you download Outlook Express from the Microsoft Internet Explorer homepage. For more information about accessing newsgroups, visit the msdn web site.

Extracted from: http://www.microsoft.com/china/msdn/archives/others/vstudio/mobilewebforms.asp


Related Article

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.