Friday, July 16, 2010

A Simple ASP NET Tutorial

Many web page designer may believe that an asp net tutorial is only for Microsoft Windows users and that it is not a technology for Linux. However, asp net can now be used on both Windows and Linux and so this is a good time for any Linux web page designers to consider that asp net tutorial.
Getting Linux ready for the ASP NET Tutorial

If a Linux programmer wishes to start an asp net tutorial then they will need a server that can support asp. In the case of Ubuntu that's the mono xsp2 server:
sudo apt-get install mono-xsp2 mono-xsp2-base

And, once they've installed the server they can also install a set of examples:

sudo apt-get install asp.net2-examples

With the server in place, it's then just a matter of starting it:
xsp2 --port 8082 --root /usr/share/asp.net2-demos/

In this case the server will use port 8082 (so that it can be run in conjunction with Apache) with the demo directory being set as the htdocs directory. However, if they do not need access to the demos, the developer may set the htdocs folder to be one in their own home area:
mkdir ~/projects/asp xsp2 --port 8082 --root ~/projects/asp

It's now time for them to consider that asp net tutorial.
A Simple Asp Net Tutorial

The server is accessed via a web browser using the url http://localhost:8082, although at the moment this will just return an error. The first job, therefore is to create "index.aspx" in the htdocs folder (in this case ~/projects/asp):

cd ~/projects/asp gedit index.aspx

The next step in this asp net tutorial is to add some code to this file:
<%@ Page Language="C#" %> < runat="server"> void Page_Load() { lblText.Text = "The date and time is: "; lblTime.Text = DateTime.Now.ToString(); } < /script> < id="lblText" runat="server"> < id="lblTime" runat="server">

In this example a simple label is updated with the current date and time when the page loads. It's also worth noting some important points about the code used in this asp net tutorial:

* the language being used is not Javascript but is c# (or C-Sharp);
* the code is run at the server (the web host) and not at the client (the user's pc);
* the code will not appear on screen if the user examines the web page source. This is, of course, because the code is run on the server and not on the client. Javascript, on the other hand, is downloaded onto the user's pc and run there.

SOURCE:
http://asp-programming.suite101.com/article.cfm/a-simple-asp-net-tutorial

No comments:

Post a Comment