Delphi.net Basics
  Home  |  Delphi .net Home  |  ASP.Net applications
 .NET Framework
 Namespace References

 System
 System.Collections
 System.Drawing - download only
 System.Globalization
 System.IO

 Articles and Tutorials

 Overview of .NET
 Delphi and .NET
 Winform Applications
 ASP .Net Applications
 ASP Web Services
 Framework Collections
 Framework String Handling
 Framework Files and Folders


 Author links

 

 
 
 ASP.Net applications
.Net Internet applications
There are many many ways of writing web pages. With ASP .Net, Microsoft introduce another mechanism. An ASP .Net application must run on an ASP .Net enabled server - ASP .Net pages have the aspx suffix.
 
The advantage of developing in ASP .Net is that you build the application in much the same was as a Windows application - with graphical components added to a form, and Delphi code used to manage component events.
 
The components are themselves converted into HTML (Hyper Text Markup Language) code, and the Delphi code is executed on the server as if it were PHP or ASp code.
 

Creating a simple ASP .Net application
We start by using the File | New | ASP .Net Web Application menu option. You are presented with a New ASP .Net Application form that asks for the name, location (folder) and server for storing the application. ASP .Net applications need to live in a server file that is registered to recognise ASP .Net applications. You'll need to be running Windows XP Professional to be able to develop ASP .Net applications - the installation of Delphi for .Net will configure your machine to run IIS or another ASP .Net compliant server.
 
On the author's machine, the new application will have the following values :
 
 Name     NeilsFirstWebApplication
 Location c:\inetpub\wwwroot\NeilsFirstWebApplication
 Server   Internet Information Server (IIS)

You will then be presented with a web equivalent to a Windows form. It is a large dotted canvas onto which you can add components. Let's add a Button and TextBox. But beware that there are a number of ways of adding buttons and labels! For our purposes, do not use the Html Elements list. We want our button to have events attached, so we must select it from the Web Controls list - Delphi aware components. The components should look like this (note the little arrow at the top left of each component) :
 

 
We want to change the Text property of the label to be blank. This is done in the Properties panel on the left of the screen after selecting the label component on the form.
 
Now double click the button to generate code. Add a simple assignment to the label as below :
 
 procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
 begin
   Label1.Text := 'Hello World';
 end;

When you run the code, you might, like myself, get an error indicating that the server could not run the code. A second run of the code overcame this problem, but quite why is unclear.
 
When it runs, a web browser window (normally Internet Explorer) will open, and the page will be loaded. Press the button and the screen should look something like this :
 

 
 
'
'
'
Delphi Programming © Neil Moffatt All rights reserved.  |  Home Page