Create a mobile network application with Mobile Web Form in Visual Studio .NET

xiaoxiao2021-03-06  93

In the past few years, the world has been seen as an explosion of new equipment - including Internet telephony and international internet - making personal digital assistance be possible - it guarantees the next generation of software you created today. When this explosion is developed to consumers or organizations, there are wide variety of equipment options, which requires developers to fight with equipment and equipment.

To help developers create applications for these new "thin customers" equipment, Microsoft has integrated Mobile Internet Toolkit directly into the Visual Studio .NET environment.

The new integration toolbox and Visual Studio .NET set up make the application make it easy to get favorable features that belong to the devices, it can be smart to adapt to different devices. Now you can create a mobile web application project in Visual Studio .NET and use visual designers to create and edit mobile web pages. You can order Visual Studio .NET Beta 2 or you can download Mobile Internet Toolkit from the MSDN® website.

Mobile Internet Toolkit consists of a series of server-side mobile network forms and Mobile Internet Designer, which also includes the QuickStart wizard, development document, and device adapter source code.

Mobile Web Forms Controls the ability to expand the ASP.NET and .NET framework to help developers create mobile network applications for cellular phones and Personal Digital Assistants, such as Pocket PC. These controls use the translation of different devices and generate appropriate label languages: Wireless Markup Language (WML) version 1.1, Hypertext Markup Language (HTML) version 3.2, or Redin HTML (Chtml).

In this article, you will learn the basic steps to create mobile network applications. Before you can create a Mobile Web Forms application, you need to install Microsoft Visual Studio .NET Beta 2 and Mobile Internet Toolkit Beta 2. With these technologies, you can create mobile web applications for cellular phones and Pocket PCs.

Mobile Web Forms Control Microsoft Mobile Network Form Control is built on the .NET Framework, which brings the advantage of the ASP.NET network development model to the world of mobile applications. In addition, mobile network form control is provided:

World Wide Tools: Fully support from the Visual Studio Integration Development Environment (IDE), using its rich toolbox and designer, drag and drop server control, automatic configuration, and many other features. Support a wide variety of devices: use ASP.NET to aim a lot of mobile devices - from thin customers to XML-based mobile phones to HTML-based Pocket PC. Write a web page: Write a web application and configure it to any supported mobile service. You can use a series of mobile network form control to write complex applications, do not need knowledge of WML and other specified languages. Intelligent server control processing a lot of implementation differences in browsers, devices, and gateways. Domesticability and scalability: benefit from the customization and expansion characteristics of ASP.NET. In addition, the scalability model will enable other devices to be supported in the future. This ensures that the future products of the convenience will support your mobile web applications you have written today.

The Mobile Web Forms Mobile Web Forms page is dedicated to the ASP.NET Network Forms page. It is a text file with a .aspx extension, and it contains a set of mobile control -asp.net server control - it can adapt to the environment provided by the supported mobile device. As a developer, you can use the device independent properties, methods, and events to schedule 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 that device. For example, some devices can display more lines than other devices, some devices can display graphics when otherwise, and some devices can place phones. Each mobile network form page must have the following standard header indication, which means it is a mobile page. Language = The property will be a wide range of languages ​​that are used for your page. <% @ Page Inherits = "System.Web.ui.MobileControls.Mobilepage" Language = "C #"%> <% @reg Tagprefix = "Mobile" namespace = "system.web.ui.mobilecontrols"

AskMBLY = "System.Web.Mobile"%>

Because a mobile network form page contains mobile control, each mobile control strip should include runat = "server" properties:

Each page contains at least one mobile form and is indicated by the label. However, you can put multiple forms into a mobile network form page. Just like other ASP.NET server controls, mobile control can publish an object model that contains properties, methods, and events. You can use this object model to modify and access this page. The object model of the mobile control is independent of the device, so you can use a unified method to affect each other, regardless of the target device. Two ways to create a mobile network Form page In Network Forms Match Microsoft Visual Basic® developers write traditional Microsoft Windows® applications. In order to build a Windows Form Application in Visual Basic, you add a form to the project, drag and drop a control to the form, set the property and double-click control to write the code running behind 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 principle and production level to mobile network applications. In order to create a wide range of mobile network applications using a mobile network form, you simply add a new mobile network form to your project, drag the control to the web, and double-click control to add running on the page. Code. You can select your business logic language for your mobile network form page. Visual C # .NET, Visual Basic .NET and Visual C ® are included in the Visual Studio .NET. The following example demonstrates how you can create mobile web applications (including in Microsoft Mobile Internet Toolkit) using Visual Studio .NET Toolkit and command lines. Visual Studio .NET Mobile Internet Designer Using Visual Basic .NET and Calendar Control to demonstrate multiple forms that define the definition in a mobile network form page. When a page is first visited by a customer, this first appearance page is the default display. You can have planned Set the ActiveForm properties of the mobile page to move to other forms, or you can allow a user to transfer to a form by using Link control. The following example demonstrates a page with two forms, and an ActiveForm navigation example. Create TwoformSapp First, create a new directory called Twoformsapp. Visual Studio is installed on a non-product test computer that is listed in a list of operating systems that run the Visual Studio .NET Beta 2 System Requirements list. NET Beta 2 and Mobile Internet Toolkit. Start Visual Studio .NET Beta 2 from the File menu, 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 name of the project, then click OK. Figure 3. New Project dialog Create a MobileWebform1.aspx User interface By default, when you create your application, the mobile network form page calls MobileWebform1.aspx. This It is a user interface file. According to the ability of the client device, it contains many server-side mobile control and HTML 3.2, chtml or WML 1.mobilewebform1.vb, a compiled background code file, will be created later to handle you. Programming logic.

From the Mobile Forms toolbar, drag a Label, a TextBox and a Command button to Form1. Click Label in Form1. Determine the Properties window in the lower right corner of your screen. Enter: Enter the date (mm / dd / yyyy) in the Label1 Text Domain. This text is displayed in the Label of the form. Change the Text property for the Command button to display Form2. Drag an additional form to the design surface below Form1. The new form is called FORM2. Add a COMMAND button and a Calendar control. Change the Text property of the Command button to display Form1. When designing, your form surface should be shown in Figure 4. Figure 4. Visual Studio .NET Mobile Internet Designer Create MobileWebform1.aspx.vb Background Code File Double-click the Show Form2 button. A new file, MobileWebform1.aspx.vb is open. Your pointer will be in Public Sub Command1_Click. 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.selectedDDATE = DateText

Calendar1.visibledate = datext

End Sub In Design, double-click the Show Form1 button. Your pointer will now be in Public Sub Command2_Click. Add the following code: private submmand2_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 TwoformsApp Application

In Solution Explorer, right-click the MobileWebForms1.aspx file and select Set As Start Page. Save your app and press F5 to create and debug it. Alternatively, select the START form from the Debug menu. When the application is running, enter the date in a specific form, then click the Show Form1 button. Form2 appears and shows Calendar control. To select a different date, click the calendar, then click the Show Form2 button. In order to test applications using mobile devices, your network service will need a fixed IP address. Microsoft Mobile Internet Toolkit and command line Visual Studio .NET Beta 2 integrates Mobile Internet Toolkit to the development environment, making many design, development, and commissioning to automate. However, mobile applications can also be created manually using the editor you like, Mobile Internet Toolkit, and command line. The following example demonstrates how to use C # to do this. It also demonstrates how you process the onclick event from Command control. When the code receives this event, it navigates to another form by program. A new active form generates onactivate events, you can control it to initialize the form. Create NameApp On a non-product test computer running Windows 2000 Server or a Windows 2000 Professional operating system with Service Pack 1, create a directory C: / INETPUB / WWWWROOT / NAME. From Internet Services Manager, expand the DEFAULT web site list, right-click Name, then click Properties. In Application Settings, the right side of Application Name, click the Create button. In the following example, you will create two files in the Name directory.

Name.aspx is a user interface file that contains a large number of server-side controls and HTML 3.2, chtml or WML 1.1 environmental translation. Name.cs is a background code file, which is a compiled C # part. The extension of this file is different based on the language used. If the part is a Visual Basic component, this file name is Name.vb. Create a Name.aspx mobile network form <% @ page codebehind = "name.cs" inherits = "nameapp.namepage" language = "c #"%>

<% @ Register tagprefix = "mobile" namespace = "system.web.ui.mbilecontrols"

AskMBLY = "System.Web.Mobile"%>

What is your name?

Create a Name.cs background code file Using System;

Using system.Web.ui.mobileControls;

Namespace NameApp

{

Public Class Namepage: MobilePage: MobilePage

{

protected form secondform;

Protected textbox name;

Protected ui.label greeting;

Private string greetingtext;

Protected void gocommand_onclick (Object Sender, Eventargs E)

{

GreetingText = "Hello," NameEedit.text "!";

Activeform = SecondForm;

}

Protected Void SecondForm_onActivate (Object Sender, Eventargs E)

{

Greeting.text = GreetingText;

}

}

}

Compile Name.cs file

Create a folder named extension in the Name directory. Enter the following code to compile Name.cs files: c: / inetpub / wwwroot / name> csc /r :system.web.dll /r:system.web.mobile.dll _ / target: library / out : bin / nameapp.dll name.cs Browse http: //localhost/name/name.aspx and test the application in a PC, a Pocket PC or any current test device listed below. Current test equipment

转载请注明原文地址:https://www.9cbs.com/read-105565.html

New Post(0)