The Request object corresponds to the request message of the HTTP protocol, and the Response object corresponds to the response message of the HTTP protocol.. Request & Response.[r]
(1)Session
(2)Review
Active Server Pages (ASP) is a server-side scripting environment that
provides a web server with the capability to process application logic, and return standard HTML pages to the browser
Web Forms provides a form designer, an editor and debugging tools,
which can be used to rapidly build server-based, programmable user interfaces for browsers and Web client devices
The Design view displays the page layout of the web page as it
would be displayed in the browser
The HTML view displays the code that is automatically generated to
create the Web page
AssemblyInfo.cs is the file that contains information about the
project It contains information such as name, version, and culture information
Once the code has been compiled, the CLR further compiles the IL to
(3)Review Contd…
Web.config is an XML based file It holds unique configuration
information about each URL used in the project
Global.asax is an optional file that is used for handling
application-level events
The web page created either using the editor or Web Forms, is first
complied to Intermediate Language (IL), including server scripts
The different web pages of an application created using Web Forms,
and the program code within it, are compiled into a single assembly / dynamic link library (.dll) file
In the editor based web application, separate dynamic link libraries
(.dll's) are created for each file
The web pages created using Web Forms, will have the Codebehind
(4)Objectives
Explain the basics of ASP.NET
Discuss the process flow of a aspx
page
Explain the Page_Load event
Discuss the IsPostBack property of
the Page object
Use the Request and Response
(5)An ASP.NET Page
Page Directive <SCRIPT> section Page_Load Event
Event Handler
HTML Control
(6)An ASP.NET Page - Output
Output after the Page Load Event
(7)Starting with ASP.NET
<%@ Page Language=”C#” %>
<script language = "C#" runat="server">
(8)<input type="button" id="Submit" runat="server" value="Click"/>
<asp:button id=”Submit” onclick="click_button"
text="Click me" runat="server"/>
(9)LABEL
Click Me
Hello World
void
click_btn(Obj ect sender, EventArgs e) {lbl.Text= "Hello
World";}
(10)Event Handlers - Example
<% @ Page Language = "C#" Debug = "true"%> <html>
<script language = "C#" runat="server">
void Page_Load(Object sender, EventArgs e) {
//code for page load }
void buttonRefresh(Object sender, EventArgs e) {
(11)Example Contd…
</script> <body>
<form runat="server">
<asp:button id="btnRefresh"
onclick="buttonRefresh" text="Refresh" runat="server"/> <br>
(12)_VIEWSTATE
Name
E- mail
Password
Submit King
K@usa.net
****** Name
E- mail
Password
(13)Page_Load Event
Database Hello
(14)Process Flow
Execution on the server
1&2 3
(15)(16)(17)(18)Virtual Directories
ASP.NET application is a collection of text files that are stored in a directory and its sub-directories on the Web server
The base directory is called the virtual root, and the
directory in which the application files are stored is called the virtual directory
The web server manages the virtual directory settings, permissions and user access
(19)Virtual Directory - Permissions
(20)To create a virtual directory :
1 Open the Internet Services Manager MMC
snap in
2 Expand Server name
3 Right click on Default Web Site, and select
New Virtual Directory from the pop up menu
4 Click Next on the Welcome to the Virtual
Directory Creation Wizard
(21)5 Enter an alias in the Virtual Directory Alias
screen Click Next
6 Type in or Browse the physical path of the
application root directory (which contains the files for the web site) in the Web Site Content Directory screen Click Next
(22)7 Set the appropriate access permissions
in the Access Permissions screen
8 Click Finish to complete the creation of
the virtual directory
(23)HTTP Protocol
HTTP Response
HTTP Request
The browser and the Web server
communicate using the HTTP protocol When the browser opens a page from a Web site, the browser establishes a
connection to the Web server and issues a request
The Web server processes the request, and responds by sending the required page Thus, the communication
(24)Request & Response
A request contains information about the client and some parameters
These parameters are essentially the data that is passed from the client, and is to be processed at the server
A response contains the information requested by the client browser
ASP.NET recognizes this request-and-response
communication through two built-in objects that correspond to the request and response messages of the HTTP
protocol
(25)Request & Response - Example
Input.htm
<HTML>
<BODY>
<P align=center><FONT color=red size=4> Input Page </FONT> </P>
<FORM action="welcome.aspx" id= frmLogin method=post name= LoginFORM>
<P> </P> <P>
<TABLE border=0 cellPadding =1 cellSpacing =1 style="HEIGHT: 75px; WIDTH: 346px" width="75%">
<TR>
<TD><STRONG>Enter your name</STRONG></TD> <TD><STRONG><INPUT id= txtName
(26)Request & Response - Example
<TR>
<TD><STRONG>Enter your country name</STRONG></TD> <TD><STRONG><INPUT id= txtCountry name=countryname> </STRONG></TD>
</TR> </TABLE> </P>
<P><INPUT id= btnSubmit name=submit type=submit value=Submit></P>
(27)Request & Response - Example
Welcome.aspx
<%@ Page Language="C#"%> <HTML>
<script runat="server">
void Page_Load( Object src,EventArgs e) {
String s,s1;
s= Request.Form.Get ("name");
(28)(29)Summary
The @ Page directive is used to specify attributes that affect the code
in the aspx page
The <script> section is where most of the code for providing the
required functionality is written
There are two types of server controls:
HTML Controls Web Controls
All event procedures receive two arguments from the events:
The event sender
The class instance that holds data for the event
The _VIEWSTATE control is a hidden control that is added to the
form when the form is submitted to the server
It is possible to check whether a aspx page is posted back to the
(30)Summary Contd…
ASP.NET has several built-in objects that are used to provide the
required functionality in an ASP.NET application They are the following:
Request Response Application Session Server ObjectContext
The base directory is called the virtual root, and the directory in which
we store the application files is called the virtual directory
The Request object corresponds to the request message of the HTTP
protocol, and the Response object corresponds to the response message of the HTTP protocol
The Form.Get method of the Request object is used to retrieve the
data submitted by the user