Introduction to ASP.NET
What is ASP.NET Setup ASP.NET First Example Creating a page Explaining Visual Basic .NET commands
What is ASP.NET
ASP.NET is no a software package, it a technology It is a feature that is included in other software packages The feature is actually called .NET framework .NET framework is a product of Microsoft It is the foundation many languages are built upon o Visual Basic o C# o C++ o J#
Setup ASP.NET
Three things are needed to setup a machine for ASP.NET o An operating system that supports Internet Information Server (IIS) – Windows XP Professional, Windows 2000 or Windows NT o IIS o .NET Framework The .NET Framework is available from Microsoft at no charge. It can be downloaded at www.microsoft.com, www.asp.net, or www.gotdotnet.com. You do not need an internet connection to in order to create and test ASP.NET pages.
First Example
ASP.NET pages can be built using Notepad. Your pages must run against an IIS server that supports .NET Your pages should be stored in the folder c:\inetpub\wwwroot Always save your ASP.NET pages with the .aspx file extension. If you use Notepad to create your pages, Notepad will place a .txt extension on the file. The way around this is save your file using quotes i.e. “helloworld.aspx” To test your pages you have to place the pages in the c:\inetpub\wwwroot folder.
Creating a Page
Create a folder under wwwroot. Name the folder hscc Create a new page in Notepad or Textpad Enter the following code. <%@Page Language="VB" Debug="True" %>
Hello World <% Dim TextSize As Integer %> <% For TextSize = 1 to 7 %> > Hello World from ASP.NET
<%Next%> Save the file in the hscc1 folder. The file name should be HelloWorld.aspx To test the page open your browser and type the following: http://localhost/hscc/helloworld.aspx Each time the code is changed you must save the changes and reload the browser page by clicking the refresh button.
Explaining Visual Basic .NET commands
Many commands will be explained later, but some will be explained now. Visual Basic .NET commands always are delimited in <% and %>. Visual Basic .NET commands appear as html tags The Visual Basic .Net variables are declared using the keyword Dim. The line <% Dim TextSize As Integer %> o Declares the variable Textsize. o A variable is a place to store information to be used later. o The As Integer define the type of information that will be stored in Textsize. In this case the only numbers will be stored in Textsize. The lines <% For TextSize = 1 to 7 %> > Hello World from ASP.NET
<%Next%>
o The For…Next is a loop. A loop provides a way to repeat the same commands. o The lines between the For…Next are repeated o Each time the code loops the value of TextSize changes from 1, to 2, to 3 all the way to 7. o The first time through the value of TextSize is 1 and the html code looks like the following Hello World from ASP.NET
o The second time through TextSize is 2 and the html code looks like the following Hello World from ASP.NET
o The third time through TextSize is 3 and the html code looks like the following Hello World from ASP.NET
o The loop stops when the textSize is equal to 7. o If you do a viewsource on the browser you will see all of the html code produced by the .NET code. Hello World Hello World from ASP.NET
Hello World from ASP.NET
Hello World from ASP.NET
Hello World from ASP.NET
Hello World from ASP.NET
Hello World from ASP.NET
Hello World from ASP.NET