Beginning ASP.NET

ASP.NET is Microsoft’s extension to HTML. It requires an ASP.NET compatible web server. Such as, Abyss or IIS (Internet Information Services from Microsoft). There are however plug-ins for Apache Web Server also. Before you continue you will need to know VB.NET which is required for the scripting part of the tutorial.

You don’t necessarily need a compiler to build an ASP.NET script. Any text editor will work. Let’s start by building or first aspx file. Create a new text document in your favorite text editor. Call it default.aspx. Now lets jump in, shall we?

 

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” 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”>
    <div>
    </div>
    </form>
</body>
</html>

The above is your basic ASP.NET template. Let me explain what each line does.

 

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” %>

This this tells the server to parse and attach the VB file we will write later on in the lesson.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

This is just your normal XHTML Transitional doctype.

<html xmlns=”http://www.w3.org/1999/xhtml”>

The xmls attribute declares a namespace for custom tags in an your document.

<head runat=”server”>

The runat=”server” attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts.

<title>My First ASP.NET Script</title>

Your average title tags.

</head>

Close the head tag.

<body>

Start the body of the page.

<form id=”form1″ runat=”server”>

This indicates that to start a form  named form1 and that is should be processed on the server.

<div>

Open a div tag.

</div>

Close a div tag.

</form>

Close the form.

</body>

End the body of the page.

</html>

End the HTML section of the page.

 

The body of your document will go between the open and close div tags.

Example:

<%@ Page Language=”VB” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” 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>My First ASP.NET Script</title>
</head>
<body>
    <form id=”form1″ runat=”server”>
    <div>
    <a id=”link1″ runat=”server”>Visit Nystic</a>
    </div>
    </form>
</body>
</html>

Now it’s time to create or VB code file. Create a new text document and call it default.aspx.vb. 

 

Here is your vb template:

Partial Class _Default
    Inherits System.Web.UI.Page

End Class

Pretty basic, huh?  Your custom code will between Inherits System.Web.UI.Page  and End Class.

 

Example:

Partial Class _Default
    Inherits System.Web.UI.Page
Sub Page_Load

    link1.HRef=“http://www.nystic.com
End Sub
End Class

Save both files in the same directory and upload them to your ASP.NET server.

I will go more in depth in my next ASP.NET tutorial. Until then, have fun!

Leave a comment

You must be logged in to post a comment.