Web Forms

   

Web Forms are similar to Windows Forms applications (which you've been creating and programming throughout this book). However, Web Forms are designed specifically to run in a browser over the Web. Although Web Forms are designed to run within any browser by default, you can target deployment to a specific browser to take advantage of a particular browser's features.

To create a Web Forms application, you choose ASP.NET Web Application on the New Project dialog box (see Figure 23.1). Be aware that to create and test a Web Forms application, you will have to have a Web server installed. If you don't have a Web server installed and configured, you'll receive a message similar to that shown in Figure 23.2, and you'll be prevented from creating the project.

Figure 23.1. A Web Forms project is different from a Windows Forms project.

graphics/23fig01.jpg


Figure 23.2. To create a Web Forms application, you will need to install and configure a Web server.

graphics/23fig02.gof


Comparing Windows Forms to Web Forms

Creating a Web Form application may offer many advantages. For example, to deploy a Web Form application, you have to deploy only to a Web server (not to all client machines). After it is set up on the server, users can run the program simply by pointing their browsers to the proper URL. Contrast this with the need to deploy a Windows Application to hundreds or thousands of users' computers. Another benefit of Web Forms is that applications are essentially platform independent because the code runs on the server and the browser is the only thing running on the client side. When deciding whether to make an application Windows-Forms based or Web-Forms based, consider the following.

Deployment

As mentioned previously, Windows applications built on Windows Forms are installed and executed on the user 's machine. Web Forms, however, run within a browser and therefore do not require deployment to a client machine. Rather than having to install updates on every client as you do with a Windows Forms application, with a Web Forms application you need to update only the server (which must be running the .NET Framework).

Graphics

Windows Forms include the capability to interact with the Windows graphics device interface (refer to Hour 10, "Drawing and Printing," for information on the GDI) to create intricate graphics with excellent performance. Web Forms can access the GDI on a Web server. However, round-trips are required for screen updates, which can negatively affect the performance of drawing graphics.

Responsiveness

When an application requires a high degree of interactivity with the user (such as screen updates, lots of event code, and data validation), Windows Forms provide the best performance because they run on the client machine. Most interactive processes with Web Forms require round-trips to the server, which again can negatively affect the responsiveness of an application.

Text Formatting and Control Positioning

Windows Forms provide exceptional capability of placing controls (for example, Windows Forms support snapping to grids). Displaying text on a Windows Form, however, requires using controls such as a label or a text box. Making text flow on a Windows Form (such as flowing around other controls when adjusting to the sizing of a form) can be very difficult to accomplish. In addition, formatting text can be problematic because most controls support only one font at a time.

Web Forms, on the other hand, are served to clients as HTTP Web pages, which excel at formatting and flowing text. Web Forms aren't as precise as Windows Forms when it comes to placing controls, however.

.NET Platform Installation

To run a Windows Forms application, users must have the .NET Framework installed on their computer. Web Forms, however, are installed on the server; therefore, the .NET Framework must be installed on the server but isn't needed on the client. The client needs only a Web browser. It is important to note that future service packs of Windows will likely include the latest .NET Framework ”but don't depend on this.

Security and System Resources

Windows Forms applications can have complete control over system resources such as the Registry and also may be restricted using the operating system's security features. Web Forms are restricted by the user's browser security settings and thus have very limited access to system resources.


   
Top


Sams Teach Yourself C# in 24 Hours
Sams Teach Yourself Visual Basic 2010 in 24 Hours Complete Starter Kit (Sams Teach Yourself -- Hours)
ISBN: 0672331136
EAN: 2147483647
Year: 2002
Pages: 253
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net