CIS 397—Web Design - Missouri State University
Download
Report
Transcript CIS 397—Web Design - Missouri State University
CIS 375—Web App Dev II
ASP .NET 2
Introducing Web Forms
What is ASP.NET Web Forms?
The ASP.NET Web Forms page framework is a
scalable common language runtime programming
model that can be used on the server to dynamically
generate Web pages.
The ASP.NET Web Forms framework provides:
The ability to create and use reusable UI controls that can
encapsulate common functionality and thus reduce the
amount of code that a page developer has to write.
The ability for developers to cleanly structure their page
logic in an orderly fashion (not "spaghetti code").
The ability for development tools to provide strong
WYSIWYG design support for pages (existing ASP code is
opaque to tools).
2
Writing Your First Web Forms Page
ASP.NET Web Forms pages are text files with an
.aspx file name extension.
______
An ASP.NET page can be created by taking an
existing HTML file and changing its file name
extension to .aspx.
VB Intro1.aspx [Run Sample] | [View Source]
3
Using ASP <% %> Render Blocks
ASP.NET provides syntax compatibility with existing
<% %> code
ASP pages including support for _________
render blocks.
VB Intro2.aspx [Run Sample] | [View Source]
Important: Unlike with ASP, the code used within
the above <% %> blocks is actually compiled--not
interpreted using a script engine, resulting in
___________
improved performance.
ASP.NET page developers can utilize <% %> code
blocks to dynamically modify HTML output much as
they can today with ASP.
VB Intro3.aspx [Run Sample] | [View Source]
4
Introduction to ASP.NET Server
Controls
Instead of using <% %> code blocks to program
dynamic content, ASP.NET page developers can use
ASP.NET server controls to program Web pages.
Server controls are declared within an .aspx file using
custom tags or intrinsic HTML tags that contain a
runat=“_______"
server attribute value.
VB Intro4.aspx [Run Sample] | [View Source] | [ads.xml]
client
Note also that no _______-side
script is required.
ASP.NET enables developers to utilize richer custom
controls on their pages, such as the
<asp:adrotator> control. (see Server Controls)
VB Intro5.aspx [Run Sample] | [View Source]
5
Handling Server Control Events
Each ASP.NET server control is capable of exposing
object model containing properties, methods,
an _______
and events.
ASP.NET developers can use this object model to
cleanly modify and interact with the page.
VB Intro6.aspx [Run Sample] | [View Source]
This simple sample is functionally equivalent to the
"Intro3" sample demonstrated earlier in this section.
Note, however, how much cleaner and easier the
code is in this new server-control-based version.
6
Using Custom Server Controls
45 built-in server controls that
ASP.NET ships with ____
can be used out of the box.
See Web Forms Controls Reference
Developers also can use controls developed by
______-party
vendors.
third
The following sample shows a simple calendar
control.
VB Intro7.aspx [Run Sample] | [View Source] | [Acme.vb]
This Calendar control performs "uplevel-like"
processing on IE 5.5 (doesn’t require round trips
back to the server when doing calendar navigation)
and "downlevel" processing on all other browsers.
7
Lists, Data, and Data Binding
ASP.NET has a built-in set of data _____
grid and list
controls for UI driven from queries against a
database or other data source.
__________
The following demonstrates how to use the
<asp:datagrid runat=server> control.
VB Intro8.aspx [Run Sample] | [View Source]
The <asp:datalist runat=server> control enables
end users to exactly control the structure and layout
of each item within the list (using the
ItemTemplate template property).
VB Intro10.aspx [Run Sample] | [View Source]
8
Form Validation Controls 1
validation server
ASP.NET provides a set of ___________
controls to check input forms for errors, and display
messages to the user.
There are controls for specific types of validation,
range checking or pattern matching, plus
such as _______
a RequiredFieldValidator.
The following demonstrates how to use two
<asp:requiredfieldvalidator runat=server>
controls.
VB Intro11.aspx [Run Sample] | [View Source]
9
Form Validation Controls 2
Validation controls have both ________
uplevel (validation on
the client and on the server) and downlevel client
support (only on the server).
ASP.NET page developers can check the
Page.IsValid property at run time to determine
whether all validation server controls on a page are
currently valid.
This provides a simple way to determine whether or
logic
not to proceed with business _______.
VB Intro12.aspx [Run Sample] | [View Source]
10
Code-Behind Web Forms
ASP.NET supports two methods of authoring dynamic
pages.
The first is the method shown in the preceding
samples, where the page code is physically declared
.aspx file.
within the originating ______
An alternative approach--known as the code-behind
method--enables the page code to be more cleanly
separated from the HTML content into an entirely
separate file.
VB Intro13.aspx [Run Sample] | [View Source] |
[Intro13.vb ]
11
Summary
1.
2.
3.
4.
5.
6.
7.
8.
Web Forms provide an easy and powerful way to
ASP.NET _____
build dynamic Web UI.
ASP.NET Web Forms pages can target any ________
browser client
(there are no script library or cookie requirements).
ASP.NET Web Forms pages provide syntax compatibility with
ASP pages.
existing _____
ASP.NET _______
server controls provide an easy way to
encapsulate common functionality.
45 built-in server controls. Developers
ASP.NET ships with ___
can also use controls built by third parties.
ASP.NET server controls can automatically project both
downlevel HTML.
uplevel and ___________
ASP.NET _________
templates provide an easy way to customize the
look and feel of list server controls.
validation controls provide an easy way to do
ASP.NET __________
12
declarative client or server data validation.