Creating Web Applications


Now comes the fun part ”developing a browser-based application using Visual Studio .NET. For old-timers, you might remember a tool called Visual Interdev, which provided basic capability for developing Web applications using ASP. Visual Studio .NET, the same environment used to develop console and Windows applications, now provides integrated development capability for developing and testing Web applications as well. First, create a new project; select Visual C# Projects and ASP.NET Web Application (see Figure 5.16).

Figure 5.16. Creating a Visual C# ASP.NET Web application.

Notice that in this case, instead of a file directory for storing the project files, a URL is posted in the location of the project ( http://localhost/WebApplication1 ). Use that and click OK. Visual Studio .NET then creates a new Web project at that URL. When the new project is opened, you will notice it is similar to the Windows forms designer; a Web forms designer is now opened for the Web application, shown in Figure 5.17. Essentially, Visual Studio .NET brings the two development and deployment approaches of application development, Web and Windows, closer by uniting the look and feel for the application developer.

Figure 5.17. ASP.NET Web form designer.

Notice that you can easily drag and drop form items from the Web Forms toolbox into the design canvas, set properties, and develop the Web forms using much the same methodology as a Windows form, illustrated in Figure 5.18.

Figure 5.18. Adding form elements to the Web forms designer.

Building the project or solution is similar to any other project. Like the previous example, you need to set this project as the Startup Project to execute it. However, you will quickly realize that instead of a Windows (or console) application, a Web browser is started and pointed to the URL http://localhost/WebApplication1/WebForm1.aspx to run the Web application (see Figure 5.19).

Figure 5.19. Running a Web application.

The source code for the completed Web application follows :

 
 <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"     Inherits="WebApplication1.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML>    <HEAD>       <title>WebForm1</title>       <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">       <meta name="CODE_LANGUAGE" Content="C#">       <meta name="vs_defaultClientScript" content="JavaScript">       <meta name="vs_targetSchema"           content="http://schemas.microsoft.com/intellisense/ie5">    </HEAD>    <body MS_POSITIONING="GridLayout">       <form id="Form1" method="post" runat="server">          <asp:Label id="Label1"             style="Z-INDEX: 101; LEFT: 88px; POSITION: absolute; TOP: 56px"             runat="server" Width="144px">First Web Application</asp:Label>        </form>    </body> </HTML> 


Microsoft.Net Kick Start
Microsoft .NET Kick Start
ISBN: 0672325748
EAN: 2147483647
Year: 2003
Pages: 195
Authors: Hitesh Seth

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