CS143: Programming in C++

advertisement
CS 3870/CS 5870
Static and Dynamic Web Pages
ASP.NET and IIS
1
Static Web Pages
•
•
•
•
Original HTML documents
Remaining the same after created and modified
At all times and to all users
All three pages of Prog1 are static
2
Static Web Pages
• Cannot be used for business operations
• No user input
• Cannot respond to different user requests
3
Dynamic Web Pages
•
•
•
•
•
Interactive or Smart HTML pages
User input and Server Response
Web Applications
Similar to Windows programs
Prog2
4
Special HTML Controls
•
•
•
•
•
To get user input
Element INPUT
Element BUTTON
Element FORM
…
5
Control Types Created with INPUT
•
•
•
•
•
•
•
•
•
•
•
Text
Password
Checkbox
Radio box
Submit
Reset
Hidden
Button
File
Image
...
6
HTML Forms
Controls to get user input should be inside
HTML forms
7
HTML Controls and Forms
Example
View Source Code
8
HTML Standards
HTML 4.01 Specification
HTML5
9
Scripts for Dynamic Web Pages
• User Input and Server Response
• Similar to Windows programs
• Need code to respond to user input
– Client Side Scripting
– Server Side Scripting
– Combination of above two approaches
10
Client Side Scripting
•
•
•
•
•
•
•
HTML files and instruction files sent to client
Client Script
JavaScript
VBScript
Java Applets
Flash
...
11
Issues with Client Side Scripting
• Different browsers may interpret
instructions in different ways
• Database is normally at server site
• Users could view source code
12
Server Side Scripting
• Instruction files are at server site
• HTML files are generated according to user input
• Only HTML files are sent to clients
13
Issues with Server Side Scripting
•
•
•
•
Most computing is done at the server
Nothing will work when the server is down
More internet traffic
Powerful and expensive servers
14
Different Technologies for
Server Side Scripting
•
•
•
•
•
CGI (Common Gateway Interface)
JSP (Java Server Pages)
PHP (Personal Home Pages)
ASP (Active Server Pages)
ASP.NET
• ...
15
ASP.NET
• A server-side technology for creating
dynamic web pages
• Client-side scripting is incorporated
(e.g., to check input)
• VB.NET or any other language
supported by .NET
• Working with MS IIS
16
Internet Information Services (IIS)
• IIS waits and takes client requests
• IIS sends static HTML files to the clients
• IIS passes client requests to ASP.NET when
needed
• ASP.NET generates dynamic web pages
• IIS sends dynamic web pages to clients
17
Program 2
• 20 points
• Due 5 pm, Wednesday, September 16
18
Creating Folder
•
•
•
•
Solution Explore
Right Click on Web Site
New Folder
Prog2
19
Creating Web Forms
•
•
•
•
Solution Explorer
Right clicking folder
Add
Web Forms
20
Page Default.aspx
Similar to index.html
Static page for Prog2
Similar to pages of Prog1
21
Adding Content to Default.aspx
• Similar to Prog1
• Copy and Paste, including the CSS file
<body>
<form id="form1" runat="server">
<h1 class="CS3870Title">Web Protocols, Technologies
and Applications </h1>
<h2 class="CS3870Name">Qi Yang</h2>
<%-- navigation bar --%>
</form>
</body>
22
External CSS Files
in Other Locations
<head>
<link rel="stylesheet" type="text/css" href=“../StyleSheet.css" />
<title>CS3870/CS5870 – Prog2</title>
</head>
<body>
<ul class="navbar">
<li> <a href="http://www.uwplatt.edu/csse/">Absolute link </a></li>
<li> <a href=“HtmlPage2.html"/>Relative link</a></li>
</ul>
</body>
</html>
23
Page OrderingProduct.aspx
Dynamic page
Adding controls
Adding code
VB
C#
...
24
Creating Page OrderingProduct.aspx
•
•
•
•
Solution Explorer
Right clicking folder
Add
Add New Items
–
–
–
–
–
Visual basic
Web Form
File name
Place code in separate file
(Select Master Page)
25
ASP.NET Server Controls
• HTML Server Controls
– HTML server controls are HTML tags understood by the
server
• Web Server Controls
– Web server controls are special ASP.NET tags understood
by the server.
– Web server controls do not necessarily map to any existing
HTML elements and they may represent more complex
elements.
• All Server Controls must be within a <form> tag.
• All Server Controls must have the runat="server"
attribute.
26
Adding and Formatting Controls
•
•
•
•
ToolBox
Standard (not HTML)
Setting control properties
Style
–
•
Source View
Format Menu
–
Set Position
•
•
•
Absolute
Relative
CSS file
27
Event Procedures
Same as Windows programs
Compute Square Root
TextBox2.Text = FormatNumber(Math.Sqrt(Textbox2.Text), 2)
28
Formatting Output
•
•
•
•
Style in HTML source
Properties Window
VB.NET procedures in VB file
VB function
–
–
–
–
Format
FormatCurrency
FormatDateTime
...
29
Checking Input
•
•
•
•
•
Click event of button Compute
Server site scripting
Client site scripting should be better
Should do it on both sites
Control Validator
30
Validators
•
•
•
•
•
•
ToolBox
Validation Tab
ControlToValidate
RequiredFieldValidator
RangeValidator
CompareValidator
– Type
– Operator
– Value to compare
31
Validation Controls
• Validate input automatically
• We don’t check input in event procedures any more
• Must set button property CausesValidation to True!
32
Program 2
You will lose five points for each late day!
Even the server is having issues!
More to discuss next class!
33
Download