News & UpdatesProgrammingWeb programming Store My Projects
Links
Affiliates

ASP.NET Tutorial – 02 – Using ASP.NET

Choosing an IDE

To begin coding in ASP.NET you need an Integrated Development Environment (IDE) that supports the Microsoft .NET platform. The standard choice is to use Microsoft’s own Visual Studio. Several light versions of this IDE can be downloaded for free from Microsoft’s web site. The one to use for programming in ASP.NET is Microsoft Visual Web Developer.

Creating a Project

After installing the IDE go ahead and launch it. You then need to create a new project, which will manage the ASP.NET source files. Go to File->New->Web Site (File->New Web Site in Visual C# Express) to display the New Website window. From there select the “ASP.NET Web Site” template and change the language to Visual C#. Configure the name and location you want for the website and click OK.

The wizard will now create a simple website for you consisting of the file Default.aspx and its code file Default.aspx.cs, as can be seen in the Solution Explorer (View->Solution Explorer). Aspx is the file extension used for ASP.NET files and the code file has the .cs extension, because it’s a C# file.

Default.aspx

The Default.aspx file has the following content:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>Untitled Page</title>
</head>
<body>
  <form id="form1" runat="server">
 
  </form>
</body>
</html>

This is a fairly normal XHTML file, with two exceptions. First, there is an ASP tag <% ... %> at the top of the page that specifies the programming language, as well as the code file associated with this web page. Secondly, there are also the special runat=”server” attributes. This attribute specifies that the element can contain code that must be run on the server before the page is sent to the client.

Recommended additional reading:
Sams - Teach Yourself ASP.NET 3.5 in 24 Hours