Using Tools to Develop ASP.NET Applications


Another problem with ASP was that the common development tool available for developing ASP-based applications, Visual Interdev, was very different from the regular Visual Studio toolset. That has a lot to do with the fact that the ASP programming model itself was very different from Visual Basic, which was the closest language-based Windows programming model. So far in this chapter, you haven't used any integrated development tool for developing Web-based applications. However, an integrated development tool would be very useful to develop, debug, and deploy rich and manageable applications. The convergence of the Windows and Web programming models and the fact that you can use any supported .NET programming language for developing a Web application (instead of something like VBScript) makes it more attractive to use a tool to build Web applications. In this section, you'll take a look at two tools for doing soVisual Studio .NET and ASP.NET Web Matrix.

Microsoft Visual Studio .NET 2003

As introduced earlier in this book (see Chapter 5, "Getting Started with Visual Studio .NET: Tools for Developing .NET Applications"), Visual Studio .NET is the de facto (yet not the only) tool to develop, debug, and deploy Web, Windows, mobile applications, and even Web services. In Chapter 5, you took a quick look at the various wizards that are available in Visual Studio .NET to develop ASP.NET applications. Recall that Visual Studio .NET 2003 provides the capability to develop ASP.NET applications using Visual C#, Visual Basic .NET, and Visual J#. Now look at an application developed almost visually (using drag and drop) using Visual Studio .NET (C#). You can use the following steps to develop and deploy this application:

  1. Launch Visual Studio .NET.

  2. Select the New Project menu item.

  3. Select Visual C#, ASP.NET Web Application.

  4. Select Project, Add Web Form, Data Form Wizard.

  5. In the wizard, create a new DataSet by selecting the SQL Server connection properties, followed by the table that you want to generate the data-enabled Web Form for.

  6. Select Build, Build Solution.

  7. Select Debug, Start Without Debugging.

By performing the preceding steps, you will be able to generate, build, and deploy the Web application (see Figure 8.10). You might argue that because ASP.NET provides a rich control model, the code-generation capability of Visual Studio .NET isn't very useful for expert programmers. However, the features that define an IDE are still very usefulintegrated source code control management, project management, component and Web application development, step-by-step debugging (even of Web applications), and so on.

Figure 8.10. Using Visual Studio .NET wizards to visually build Web applications.

Code Behind

An important pattern used by Visual Studio .NET is the notion of code behind . Code behind means that Visual Studio .NET separates the HTML and ASP.NET control code from the actual source code of the page, which is the event-handling code and calling business logic functions. This is very useful in developing complex applications and prevents clutter of the two tierspresentation and business logic.

 
 <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"      AutoEventWireup="false" Inherits="VisualApp.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:DataGrid id=DataGrid1                style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px"                runat="server" DataSource="<%# dataSet11 %>">              </asp:DataGrid>           </form>      </body> </HTML> 

Here is the code behind for the page:

 
 using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace VisualApp {         public class WebForm1 : System.Web.UI.Page         {                ...                private void Page_Load(object sender, System.EventArgs e)                {                   sqlDataAdapter1.Fill(dataSet11);                   // Put user code to initialize the page here                }                #region Web Form Designer generated code                ...                #endregion         } } 

ASP.NET Web Matrix

If your scope for developing on the .NET platform is limited to that of developing Web applications and your investments don't permit buying a license of Visual Studio .NET, you are still in luck. A group of developers have developed an interesting, and free, tool called Web Matrix (see Figure 8.11). The tool, which is available at http://www.asp.net/webmatrix/, provides the basic capabilities for developing ASP.NET visually. Although the tool doesn't really provide full-blown IDE functionality such as those provided by Visual Studio .NET, it is definitely an attractive option for freelance developers and developers developing applications with a limited budget. Another great way of using a tool such as Web Matrix is to use it as a learning tool. In some areas, features in the Web Matrix tool are much better than those provided in Visual Studio .NET. Web Matrix is available on Windows XP, Windows 2000, and Windows 2003 platforms. In addition, SQL Server or MSDE (Microsoft SQL Server Desktop Edition) is required to develop database-enabled Web applications. It even comes with its own mini Web server for local development and testing. .NET Framework is required to be installed for Web Matrix because it is completely developed in .NET Framework. So if you are looking to develop a development tool, Web Matrix provides some light in terms of the kind of functionality you can provide using .NET.

Figure 8.11. Using ASP.NET Web Matrix to build Web applications.



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