Академический Документы
Профессиональный Документы
Культура Документы
Server
Client
movie schedule
We will use ASP.NET to run server side code
• http://www.eee.bham.ac.uk/spannm/ASP Net
stuff/MovieSite/MovieSite.aspx
The site will be an .aspx file which will look similar to our
original .html file
It will call methods from a C# class which is in a code
behind file
We will explain later how this all fits together
Static and dynamic web pages
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MovieSite.aspx.cs"
Inherits="MoviePage" %>
Page derived
managed object
.aspx file
ASP.NET
.cs file
How ASP.NET works
Web server
Page derived
managed object
html html
To client
ASP.NET
How ASP.NET works
From the 2 files, ASP.NET produces code for 2 files
The class is derived from the System.Web.UI.Page class
Web server
Browser request
Managed code and postback
data
ASP.NET
Page derived
and custom html
objects
How ASP.NET works
In our simple example, code for a derived class of the
MoviePage class is produced
An object is instantiated containing code for
method calls to WriteDate() and WriteMovies()
More realistically our page will contain web controls
which represent user interface elements on our web
page
These are defined in the FCL
Controls.aspx
Introduction to web form
programming
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebControls.aspx.cs"
Inherits="DatePage" %>
codebehind files
Typically this would be event handler
design mode
The currently designed website can be previewed at any
time
As in normal windows program development, the event
handler code for web controls (eg buttons) have to be
added by the developer
Visual Web Developer
We can create the web page for displaying the
calendar using design mode
The label, text field, button and calendar are
inserted into the page using drag and drop
We set the visible property of the calendar to
false in its properties window
We set the background colour of the outer form
using the properties windon
All code except the Page_Load() and
Button_Click()methods is automatically created
Visual Web Designer Demo
Validation controls
A validation control determines whether the data
entered in a web control is in the proper format
For example a postcode entered in the correct
alphanumeric format
A date entered in the correct dd/mm/yyyy
format
A correct email address is entered
etc
.]\w+)*
We can generate our own for a UK phone
number
((\(\+\d{2}\) ?)|(\+\d{2}-))?\d{3}-\d{3}-\d{4}
• eg (+44)(121-414-4329)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Validation.aspx.cs" Inherits="Validation" %>