Microsoft ASP.NET Programming with Microsoft Visual Basic .NET Version 2003 Step By Step

There are three basic types of ASP.NET applications, each with a distinct purpose. ASP.NET Web Applications are for a Web application that will provide its own HTML-based user interface. ASP.NET Web Services are for Web-based functionality that will be accessed programmatically. ASP.NET Mobile Web Applications, new in Visual Studio .NET 2003, are designed for creating Web applications targeted at Personal Digital Assistants (PDAs), cell phones, and other mobile devices. You can develop all of these application types with or without Visual Studio .NET, although the Visual Studio environment makes developing them significantly easier and faster. The following illustration shows the Visual Studio .NET New Project dialog box displaying the ASP.NET Web Application, ASP.NET Web Service, and ASP.NET Mobile Web Application project templates for Visual Basic .NET (some of the project templates shown might not appear in all editions of Visual Studio .NET).

ASP.NET Web Applications

ASP.NET applications, at their simplest, are much like classic ASP applications. The elements of a simple ASP.NET application are

For Visual Studio .NET users, the good news is that all of the preceding files are created for you when you create a new Web application project.

ASP.NET Web Forms

Web Forms are an important part of any ASP.NET Web application. Put simply, they are ASP.NET pages that use ASP.NET Server Controls. The Web Forms programming model makes it possible (and relatively easy) to develop Web- based applications in much the same way that today’s Microsoft Visual Basic programmers develop Microsoft Windows–based applications that have a GUI.

Web Forms in Visual Studio .NET allow you to create rich, interactive applications simply by dragging and dropping controls onto a page and then writing minimal code to handle user interaction, events, and so on. In addition, the Visual Studio .NET environment lets you work on your pages either visually— using the Web Forms Designer—or textually, using the powerful Visual Studio .NET source-code editor.

You can write code in your Web Forms in one of two ways: inline in the .aspx file (as is typical of a classic ASP page), or using a code-behind module. Although it’s possible to write your application with code in the actual .aspx file and still take advantage of compiled code and the other improvements of .NET, I recommend that you get in the habit of using code-behind modules. Visual Studio .NET defaults to using code-behind for UI-specific programming logic.

Code-Behind

Code-behind is a new feature in ASP.NET that allows developers to truly separate the HTML and tag-based UI elements from the code that provides user interaction, validation, and so on. Code-behind modules offer developers a number of advantages:

All in all, it’s worthwhile to get into the habit of using code-behind. You’ll see examples of code-behind throughout the book.

ASP.NET Web Services

Although no one would deny that Web applications created with ASP.NET (or even with classic ASP) can be very useful, one feature that has long been missing is an easy way to provide programmatic functionality over the Internet or an intranet without tying the client to a specific UI. This is where ASP.NET Web services come in.

A Web service, at its simplest, is a chunk of programming code that is accessible over the Web. Web services are based on the World Wide Web Consortium’s (W3C) SOAP specification. This allows computers on varying platforms, from Windows servers to UNIX workstations, to offer and consume programmatic services over the HTTP protocol.

Note

SOAP can use other protocols, such as FTP or SMTP, but HTTP is the most common protocol used with SOAP and Web services because most firewalls allow communication via the HTTP protocol.

ASP.NET makes it remarkably easy to implement Web services. In fact, all it takes is adding an appropriate declaration to any method you want to make available as a Web service. Visual Studio .NET makes it even easier by taking care of all the work necessary to make your Web service available to potential clients. Part IV will discuss Web services in greater detail.

ASP.NET Mobile Web Applications

Like standard ASP.NET Web applications, ASP.NET Mobile Web applications contain a number of standard elements:

As with the ASP.NET Web Application template, Visual Studio .NET creates all of the preceding files when you create a new ASP.NET Mobile Web application project. You’ll learn more about developing ASP.NET applications for mobile devices in Chapter 8.

Категории