Describe the following: Explain Active Server Pages Explain the features of ASP.NET... Web-enabled Application ArchitectureProxy Server Internet Web server Certificate Client 1 Browser
Trang 1Chapter 1
Introduction to Web
Applications and ASP.NET
Trang 2Describe the following:
Explain Active Server Pages
Explain the features of ASP.NET
Trang 3Client 1
Client 2
Client/Server and Web Applications
ASP.NET and Webforms / Chapter 1/ Slide 3 of 22
Trang 4Web-enabled Application Architecture
Proxy Server
Internet
Web server Certificate
Client 1
(Browser)
Database Server
server HTTP
Certificate Server
Server-based programs
ASP CGI ISAPI
Other servers
FTP SMTP Exchange Server
Trang 6Network Interface and HTTP Service
Network Interface
Transport Layer
and
Internet
and Internet Layer (TCP / IP)
Windows Sockets
Trang 7Accessing Database Information
Web server HTTP
Trang 8Web Application Development Cycle
Designing the application
Planning the Web application
Constructing and testing the components of the application
Going live
Production and maintenance
Trang 9Web Application Development Process
Functional specifications
No
Design phase
complete?
Design complete?
Yes
Complete?
Going live
Production and maintenance
No
Yes No
Yes
A
Trang 11JavaScript data validationdata validation
Data valid?
Valid Data Submit data to serverto server
Yes
No
Trang 12Client-Side Scripting
Provide user interaction
Dynamically change content
Validate dataIntegration
<script language="JavaScript">
JavaScript statements;
Trang 13Active Server Pages
<HTML><BODY>
<CENTER><I><FONT COLOR="HOTPINK" size = 5>
<%If Time >= #12:00:00 AM# And Time < #12:00:00 PM# Then%>
"Now the time is between 12:00 am and 12:00 pm"
Trang 14Processing of ASP File
Trang 15Advantages of ASP
Trang 16ASP File in a Web-based Application
Active ServerPages (ASP)JavaScriptVBScript
Active Server Pages (ASP)JavaScriptVBScript
Trang 17Evolution of ASP.NET
Trang 19Advantages of ASP.NET
Compiled pages improve execution speed
Supports strongly typed languages like C#, VB
Compiled pages improve execution speed
ASP code is separated from the HTML design
and text Provides declarative server controls
Trang 20Advantages of ASP.NET (Contd.)
Supports re-use of code by the inheritance
An inbuilt method, Trace, helps to debug a page
Supports re-use of code by the inheritance
mechanism
No need to register component
Trang 21Features of ASP.NET - 1
Adds functionality using C# or VB.NET
Uses server - side caching
ASP.NET
Ships with many in-built server controls
Recognizes the type of client browser and accordingly displays the contents to the client
Trang 22Features of ASP.NET - 2
Refers hierarchical namespaces
Global.asax file holds
Global.asax file holds additional events
Web service - a function deployed and used over the Web
ASP.NET
Trang 23Chapter 2
ASP.NET Objects
Trang 24Explain the basics of ASP.NET
Discuss the process flow of an ASP.NET Page
Explain the Page_Load event
Explain the Page_Load event
Use the Request and Response objects
Trang 26HTML Control
An ASP.NET Page– 2
Web Control
Trang 27Starting with ASP.NET
Trang 28<input type="button" id="Submit" runat="server" value="Click"/>
Trang 29t sender,EventArgs e)
Trang 31Page_Load Event
World
Trang 32Process Flow
Execution on the server
HTTP Request
HTML
6
3
User causes Postback
4
LPage
Values
after
Postback
Changes are processed
7
HTMLPage
5
Trang 33ASP.NET Objects -1
Trang 34ASP.NET Objects –2
Trang 35ASP.NET Objects – 3
Trang 36Virtual Directories
Trang 37Permissions
Trang 38HTTP Protocol
HTTP Response HTTP
Request
Trang 39Request and Response
Trang 40Response.Redirect
Trang 41Chapter 3
ASP.NET Controls
Trang 42Explain Web controls
Identify the Object model
Use:
Use:
Discuss rich controls
Trang 43Web Controls
ASP.NET
ASP.NET Controls
Trang 44TextBox
Trang 45Object Model - 2
<html><script language="C#" runat ="server" >
void click1(Object Src, EventArgs E){
<asp:textbox id="cur_obj" size = 40 runat="server"/> <br><br>
<asp:button type = submit text= "Say Hello!!!" OnClick="click1" runat =
"server" /><br>
</form>
</body>
</html>
Trang 47<asp:textbox id="name" runat="server"/>
Text Entry - Intrinsic Control
Single-line entry
Multi-line entry
<asp:textbox id="add" textmode="multiline"
rows="5" columns="10" runat="server"/>
<asp:textbox id="pass" textmode="password"
runat="server"/>
Multi-line entry
Password entry
Trang 48Control Transfer - Intrinsic Control
Navigate between the pages
Trang 49Difference in Intrinsic Controls code
Trang 50<asp:checkbox id = "chk1" Text = "have U selected me" runat="server"/>
<asp:radiobutton id ="rad1" Text =" button 1" groupname="radio" runat="server"/>
Selection - Intrinsic Control - 1
CheckBox
RadioButton
<asp:radiobutton id ="rad1" Text =" button 1" groupname="radio" runat="server"/>
<asp:radiobutton id ="rad2" Text =" button 2" groupname="radio" runat="server"/>
<asp:radiobutton id ="rad3" Text =" button 3" groupname="radio" runat="server"/>
<asp:listbox id="lb" runat="server"/>
<asp:dropdownlist id= "ddl" runat="server" />
ListBox
DropDownList
Trang 51Data Populating Methods of
Selection Intrinsic Control
void Page_Load (Object Src, EventArgs E)
<asp:listbox id="lbs" runat="server">
<asp:ListItem> One </asp:ListItem>
<asp:ListItem> Two </asp:ListItem>
<asp:dropdownlist id= "ddl" runat="server" >
<asp:ListItem> One </asp:ListItem>
<asp:ListItem> Two </asp:ListItem>
<asp:ListItem> Three </asp:ListItem>
</asp:dropdownlist>
Trang 52Container controls can contain other controls
One of the main uses of container controls is
that the visibility of a group of controls can be changed at one point by placing them in a
container control, and setting the property of
Container
<asp:panel id="pan" Visible="False" runat="server" >
<asp:textbox id="pass1" textmode="password" runat="server"/>
<asp:textbox id="pass2" textmode="password" runat="server"/>
</asp:panel>
container control, and setting the property of
the container control
Trang 53Rich Controls
Used for changing
the advertisements
on the Web pages
Gives full functionality
of a calendar
Trang 54Category assigned to the ad Priority of the advertisement
in the schedule of rotation
Trang 55AdRotator - 2
Trang 56Calendar control responds to two events:
Calendar Control
Trang 57Chapter 4
Advanced Validation Techniques
Trang 58Explore the various Validation controls
Explain code behind
Implement code behind
Trang 59Validation Controls
Restricts blank fieldCompares two fieldsChecks for specified range
RequiredFieldValidator
CompareValidator
RangeValidator
Checks value with expression
Checks value of client-side
Trang 60Inline error message
RequiredFieldValidator
entered
<asp:requiredfieldvalidator controltovalidate="userid"
display="static" errormessage="You must enter your user
id." runat=server>
The User Id cannot be left Blank!
</asp:requiredfieldvalidator>
Trang 61Validation Error Message
Dynamic Display
Trang 62< asp:comparevalidator controltovalidate="pwd_con" display="static" errormessage="the confirmation password does not match."
controltocompare="pwd" type ="String" operator="Equal"
runat=server> *
</ asp:comparevalidator > = , < , > , <= , >= , Not Equal
CompareValidator
< asp:comparevalidator controltovalidate="bid" display="static"
errormessage="You cannot enter a bid for lesser than $100.“
valuetocompare =100 type="Integer" operator="GreaterThanEqual"
Trang 63< asp:rangevalidator controltovalidate="r3" type="Integer"
control for the range
Trang 64Sign Meaning
^ The caret sign ^ specifies that checking starts from here
$ The “$” sign specifies that the checking ends here
[] Square brackets “[]” checks that the value entered match with any
RegularExpressionValidator - 1
[] Square brackets “[]” checks that the value entered match with any
of the characters that are in the square brackets.
\w “\w” allows any value to be entered
/d{} “/d” specifies that the value entered is a digit, and {} specifies the
number of occurrences of the specified data type
+ The + sign indicates that one or more elements to be added to the
expression being checked
Trang 66<asp:customvalidator runat="server"
controltovalidate="grade"
clientvalidationfunction="clval"
Client-side function
CustomValidator
onservervalidate="serval" display="static">
Wrong value
</asp:customvalidator>
Trang 67<asp:validationsummary id="vs1" headertext="The
errors found are: " displaymode="singleparagraph"
runat="server"/>
ValidationSummary
runat="server"/>
</asp:customvalidator>
Trang 68Page.IsValid Property
<script language="C#" runat="server" >
void validate_page(Object Src, EventArgs E){
if (Page.IsValid == true) {
lbl.Text = "Page is Valid!";}
else {
lbl.Text = "Page is not Valid!"; }
lbl.Text = "Page is not Valid!"; }
}
</script>
Trang 69Uplevel and Downlevel Browsers
<%@ Page ClientTarget=DownLevel %>
Disable
client-side validation
Trang 70<%@ Page language="C#" Inherits="codeb" %>
<html>
<script language="C#" runat ="server" >
</script>
Provides the functionality
Trang 71public System.Web.UI.WebControls.Button bMe;
protected void bMe_Click(Object sender, EventArgs e) {
lb1.Text = "Clicked!";
} void Main() {
}
}
Trang 72Chapter 5
The Application And Server Objects
Trang 73Discuss the Global.asax file
Explain events in Global.asax file
Use the Application object
Use the Application object
Use the Server object
Trang 74Stored in the application’s root directory
Defines boundary of application
Initialize application or session level variables
Connect to databases
Send cookies
Trang 75Session_OnStart Fired every time a new session begins.
Session_OnEnd Fired when the session ends Refer to the session on
the Session object for the various ways in which a session can end.
Trang 76Events in Global.asax - 2
Trang 78Application Object - 2
<script language="C#" runat="server">
void Application_OnStart(Object sender, EventArgs E) {
Application ["greeting"] = "Welcome to my World";
Trang 79Application Object - 3
<script language="C#" runat="server">
void Application_OnStart(Object sender, EventArgs E) {
Application ["Counter"] = 0;
}</script>
<html>
<script Language ="C#" runat ="server" Debug = "true">
<script Language ="C#" runat ="server" Debug = "true">
void Page_Load(Object Src, EventArgs E){
Application["Counter"] = (Int32) Application ["Counter"] + 1;
Response.Write("You are visitor number :" + Application ["Counter"]);
}</script>
<form runat= "server" >
<MARQUEE BEHAVIOR="scroll" Scrolldelay = 25><FONT SIZE = 5
COLOR
= RED>Welcome to my World</FONT></MARQUEE>
</form></html>
Trang 80Application Object - 4
Trang 81Controlling Access
<HTML>
<script Language ="C#" runat ="server" Debug = "true">
void Page_Load(Object Src, EventArgs E)
Trang 82<script language="C#" runat="server">
void Application_Start(Object sender, EventArgs E)
{ String [] job = new String [4];
job[0]= "Faculty"; job[1]= "Programmer";
job[2]= "Salesman"; job[3]= "Manager";
Application ["j"] = job; } </script>
<<HTML> <script Language ="C#" runat ="server" >
void Page_Load(Object Src, EventArgs E) {
Trang 84Execute Method
<%@ Page Debug ="true"%><html>
<script language="C#" runat="server">
void clicked (Object Src, EventArgs E){
Server.Execute("/test/ses6ex1.aspx");}
</script>
<form runat ="server">
<form runat ="server">
<asp:button id = "btn1" onclick = "clicked" Text =" Click me to transfer execution" runat = "server" />
</form></html>
Trang 85Transfer Method
Server.Transfer("/test/transfer.aspx");
Trang 87ap.aspx"));
Trang 88URLEncode Method - 2
<html>
<script language="C#" runat="server">
void clicked (Object Src, EventArgs E)
{
String name = Server.UrlEncode("John Saunders");
Response.Redirect
<html>
<script language="C#" runat="server">
void clicked (Object Src, EventArgs E)
<form runat ="server">
<asp:button id = "btn1" onclick = "clicked" Text =" Click me
to send values" runat = "server" />
<form runat ="server">
<asp:button id = "btn1" onclick = "clicked" Text =" Click me
to send values" runat = "server" />
</form>
</html>
Trang 89URLEncode Method - 3
<html><script language="C#" runat="server">
void clicked (Object Src, EventArgs E){
String name = Server.UrlEncode("John Saunders");
String password = Server.UrlEncode("king");
Response.Redirect("http://localhost/code/error.aspx?name=" + name + " &password=" + password);
}</script>
<html><script language="C#" runat="server">
void clicked (Object Src, EventArgs E){
String name = Server.UrlEncode("John Saunders");
String password = Server.UrlEncode("king");
Response.Redirect("http://localhost/code/error.aspx?name=" + name + " &password=" + password);
}</script>
}</script>
<form runat ="server">
<asp:button id = "btn1" onclick = "clicked" Text =" Click me to send values" runat = "server" />
</form></html>
}</script>
<form runat ="server">
<asp:button id = "btn1" onclick = "clicked" Text =" Click me to send values" runat = "server" />
</form></html>
Trang 91Chapter 6 6
The Session Object
Trang 92Describe Cookies
Read and write Cookies
Explain the use of session object
Define stateliness of a session
Trang 93Cookies - 1
A cookie is a small packet of information that is
used to maintain information on the user's
computer A cookie can be temporary or
persistent
Expires when
the user leaves
the Web site
Retained on the clientmachine and can be read bythe Web server when theuser next accesses the Website
Trang 96Retrieving Data - 1
HttpCookie cookie = Request.Cookies[“cookiename”];
<html><script language="C#" runat="server">
void Page_Load(Object Sender, EventArgs E){
HttpCookie cookie1 = new HttpCookie("UserName");
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(0,0,1,0);
cookie1.Expires = dt.Add(ts);
Response.Cookies.Add(cookie1);
Trang 97<asp:Label id = "Display1" runat="server" /><br><br>
<asp:Label id = "Display2" runat="server" />
</html>