Tutorials » An Introduction to ASP.NET

ASP.NET offers a novel programming model and infrastructure that facilitates a powerful new class of applications. ASP.NET is a compiled. NET-based environment, so one can author applications in any .NET compatible language, including Visual Basic, C# and Jscript.NET. Developers can effortlessly access the advantage of these technologies, which consist of a managed Common Language Runtime environment, type safety, inheritance, and so on. With the aid of Microsoft Visual Studio.NET Web development becomes easier.

Web Forms permits us to build powerful forms-based Web pages. When building these pages, we can use Web Forms controls to create common UI elements and program them for common tasks. These controls permit us to rapidly build up a Web Form.

Web services enable the exchange of data in client-server or server-server scenarios, using standards like HTTP, SOAP (Simple Object Access Protocol) and XML messaging to move data across firewalls. XML provides meaning to data, and SOAP is the protocol that allows web services to communicate easily with one another. Web services are not tied to a particular component technology or object-calling convention. As a result, programs written in any language, using any component model, and running on any operating system can access Web services.

Advantages of ASP.NET

ASP.NET is Part of the .NET Framework

The .NET Framework comprises over 3,400 classes that we can employ in our ASP.NET applications. We can use the classes in the .NET Framework to develop any type of applications. Since ASP.NET is part of the .NET Framework, we can do all these things from within an ASP.NET page.

While ASP Classic pages are formed with scripting languages such as VBScript and JavaScript. ASP.NET pages are formed with full-blown programming languages such as Visual Basic and C#. And whereas there are five standard objects accessible in the ASP Classic Framework (the Request, Response, Application, Session, and Server objects), there are over 3,400 standard objects in the .NET Framework that we can use in an ASP.NET page.

ASP.NET Pages are compiled

When an ASP.NET page is first requested, it is compiled and cached on the server. This means that an ASP.NET page performs very rapidly. All ASP.NET code is compiled rather than interpreted, which permits early binding, strong typing, and just-in-time (JIT) compiling to native code.

XML-Based

ASP.NET configuration settings are stored in XML-based files, which are human readable and writable. Each one of our applications can have a different configuration file and we can extend the configuration scheme according to our necessities.

Code-Behind logic

The main problem with ASP Classic pages is that an *.asp page does not yield modularized code. Both HTML and Script are present in a single page. But Microsoft's ASP.NET implementation contains a new-fangled method to break up business logic code from presentation code. Each ASPX created in Visual Studio has an equivalent class written in a .NET compliant language such as C#. This class consists of event handlers, initialization code and other supporting code for the user interface in the ASPX file. The C# file that hold this class is called the code-behind file and affords the ASPX file's programmatic implementation.

ASP.NET Pages are built with Server Controls

We can easily build complex Web pages by bring together the pages out of ASP.NET server controls. For example, by adding validation controls to a page, we can easily validate form data.

Sample Program

To place a Label in the WebForm the ASPX file will look like as below.

<%@ Page Language="C#"% Codebehind="Label.aspx.cs"%>

<html>
  <head>
  <title>Simple Web Form </title>
  </head>
  <body>
    <center>
    <form id="Form" method="post" runat=server>
      <asp:Label id="Label1" runat=server>
      A Simple Web Form
      </asp:Label>
    </form>
    </center>
  </body>
</html>

Label.aspx.cs File:

using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.HtmlControls;
using System.Web.UI;
using System.Web.SessionState;
using System.Collections;

namespace Label
{
    public class LabelTest : System.Web.UI.Page

  {
      protected System.Web.UI.WebControls.Label Label1;

  override protected void OnInit(EventArgs e)
  {
     InitializeComponent();
     base.OnInit(e);
  }

  private void InitializeComponent()
  {
    this.Load += new System.EventHandler(this.Page_Load);
  }
    }
}

About the Author

G.GNANA ARUN GANESH is the Administrator and the Founder of ARUN MICRO SYSTEMS (www.arunmicrosystems.netfirms.com). He has been programming in C++, Visual Basic, COM, Java and Microsoft Technologies for 3+ years. Arun's background includes Bachelor degree in ECE.He is one of the Top authors writing articles in C# and .NET in various websites. He is an Active person in the panel of Technical Reviewers in Prentice Hall Publishers and Sams Publication. In .NET the last book he reviewed is the "C# how to program" written by Harvey and Paul Deitel. You can contact him for technological support and queries through ggarung@rediffmail.com