Uploaded by Daniel Ephraim

ASP .NET application -lecture 6

ASP .NET Introduction
• ASP.NET is the latest version of Microsoft's
Active Server Pages technology (ASP).
• Before you continue you should have a basic
understanding of the following:
– World Wide Web – WWW
– HTML and the basics of building Web pages
– Scripting languages like JavaScript or VBScript –
the basics of server side scripting
What is ASP?
ASP is a server side scripting technology that
enables scripts (embedded in web pages) to be
executed by an Internet server.
ASP is a Microsoft Technology
ASP stands for Active Server Pages
ASP is a program that runs inside IIS
IIS stands for Internet Information Services
IIS comes as a free component with Windows 2000
IIS is also a part of the Windows NT 4.0 Option Pack
The Option Pack can be downloaded from Microsoft
PWS is a smaller - but fully functional - version of IIS
PWS can be found on your Windows 95/98 CD
What is an ASP File?
• An ASP file is just the same as an HTML file
• An ASP file can contain text, HTML, XML, and
• Scripts in an ASP file are executed on the
• An ASP file has the file extension ".asp"
What is ASP .NET?
• ASP 3.0 is the latest version of ASP, but
there will never be an ASP 4.0 version.
• ASP.NET is the next generation ASP, but it's
not an upgraded version of ASP. ASP.NET is
an entirely new paradigm for server-side ASP
• ASP.NET is a part of the .NET Framework.
• Microsoft spent three years rewriting
ASP.NET from the ground up, and ASP.NET
is not fully backward compatible with ASP
The .NET Framework
• The .NET Framework is the infrastructure for the Microsoft .NET
• The .NET Framework is an environment for building, deploying, and
running Web applications and Web Services.
• The .NET Framework contains a common language runtime and
common class libraries - like ADO.NET, ASP.NET and Windows
Forms - to provide advanced standard services that can be
integrated into a variety of computer systems.
• The .NET Framework provides a feature-rich application
environment, simplified development and easy integration between
a number of different development languages.
• The .NET Framework is language neutral. Currently it supports C++,
C#, Visual Basic, and JScript (Microsoft's version of JavaScript).
• Microsoft's Visual Studio.NET is a common development
environment for the .NET Framework.
Brief History of Server-Side Programming
• Common Gateway Interface (CGI)
• Internet Server Application Programming
Interface (ISAPI)
• Internet Database Connector (IDC)
• Active Server Pages (ASP)
Common Gateway Interface (CGI)
• One of the first technologies to be introduced built into almost all
Web servers
• CGI is a method of obtaining and returning information to and from
the Web server
• CGI, as its name implies, isn’t a language, but rather an interface to
the Web server
• CGI applications can be programmed in a wide variety of languages.
Possibly the most common is Practical Extraction and Report
Language (Perl), C, Python
• Definite advantages of CGI are that it is platform independent and
built into most Web servers
• Possibly the greatest pitfall of CGI from a performance point of view
in Windows is that each client request for a CGI “Web page”
requires a new process to be created, which consumes vast
amounts of system resources
Internet Server Application
Programming Interface (ISAPI)
• Microsoft developed (ISAPI) for its Internet Information
Server (IIS) to eliminate the major performance bottleneck
of CGI: the need to create a new process for each client
• ISAPI was intended to replace CGI for IIS by allowing
developers to do everything they could by using CGI
executables, but do it with significantly less performance
• ISAPI applications are compiled as Windows dynamic link
libraries (DLLs).
• ISAPI applications run in the IIS process space, which
allows for execution faster than that of CGI applications.
• There are two different types of ISAPI applications, ISAPI
Filters and ISAPI Extensions
• ISAPI Filters run in the background and can monitor Web
server requests and perform a variety of tasks accordingly
• ISAPI Extensions are the rough equivalent of CGI
executables and run upon client request.
Internet Database Connector (IDC)
• Microsoft’s Internet Database Connector (IDC)
technology has been included in IIS since its inception
and is used to provide easy database connectivity for
Web pages
• Each page requires two files: a query file and a template
• The query file contains the database connection
information and the SQL query.
• The template file contains HTML and tags denoting
where specific data from the query file must be inserted
• This method of database connectivity was very easy to
use, but it had one major pitfall in that there was no
place to put business logic
Active Server Pages (ASP)
Microsoft combined the best features of IDC and ISAPI to produce
Active Server Pages (ASP)
ASP pages offer the ease of use of IDC by allowing database and
business logic code to be inserted directly into pages using
special tags, and they offer the performance advantages of ISAPI
ASP is very scalable, and this has been proven time and time
again with many large sites relying on ASP
ASP was a huge leap forward and offered a completely new
paradigm for dynamic Web page development when it was
ASP’s unique approach allowed for dramatic increases in
productivity and opened up the exciting area of dynamic Web
page development to many novice programmers who were
bewildered by the complexity of CGI and ISAPI
This was helped largely by the fact that the primary languages for
ASP development are VBScript and JScript
ASP.NET isn’t simply the next version of ASP—it’s a completely redesigned
technology that takes the best aspects of ASP and merges them with the
power of pure object-oriented programming (OOP), a powerful
development framework with features like:
A fully compiled environment.
An integral part of .NET and the .NET Framework.
Server controls
Event driven programming
Separation of code from content
Session state management
User input validation
Web services
Caching services
Debugging and tracing
ASP .NET-Compiled environment
•ASP.NET is a part of Microsoft .Net platform.
•ASP.NET applications are compiled codes,
written using the extensible and reusable
components or objects present in .Net framework.
•These codes can use the entire hierarchy of
classes in .Net framework.
•The ASP.NET application codes can be written in
any of the following languages:
•Visual Basic.Net
ASP .NET-An integral part of .NET
and the .NET Framework.
•.NET is a developer platform made up of tools,
programming languages, and libraries for building
many different types of applications.
•ASP.NET extends the .NET developer
platform with tools and libraries specifically for
building web apps.
•Here are some things included in the .NET
The C# programming language and its compilers
Base libraries for working with strings, dates, files/IO, and more
Editors and tools for Windows, Linux, macOS, and Docker
ASP .NET- Controls
•Controls are small building blocks of the graphical
user interface, which include
• text boxes
• check boxes
• list boxes
• labels
• and numerous other tools.
•Using these tools, the users can enter data, make
selections and indicate their preferences.
ASP .NET- Controls
•Controls are also used for structural jobs, like
•data access
•creating master pages
•and data manipulation.
•ASP.NET uses five types of web controls, which are:
HTML controls
HTML Server controls
ASP.NET Server controls
ASP.NET Ajax Server controls
User controls and custom controls
HTML controls
•The HTML controls have a one-to-one mapping
with HTML tags.
•HTML controls can be used to change their
appearance by modifying their properties.
• HTML controls have an object model that closely
resembles the HTML syntax of the elements, as
well as the Dynamic HTML (DHTML) object
HTML controls
•The attributes of an HTML tag correspond to the
properties of the HTML control.
•The HTML controls are declared by using the
standard HTML tags with the
attribute runat="server".
• For example:
•<input type="text" id="txtName" runat="server">
•The id attribute is very important for all server
controls if you plan to access your control
programmatically, since it defines the name by
which the object will be referenced in code.
HTML controls
•In ASP.NET, the following HTML tags are
supported as HTML controls:
•All <input> tags
HTML Server controls
•HTML server controls are HTML tags understood
by the server.
•HTML elements in ASP.NET files are, by default,
treated as text.
•To make these elements programmable, add a
runat="server" attribute to the HTML element(to
indicates that the element should be treated as a
server control.)
•Note: All HTML server controls must be within a <form>
tag with the runat="server" attribute!
•Note: ASP.NET requires that all HTML elements must
be properly closed and properly nested.
HTML Server controls
HTML Server Control
Controls an <a> HTML element
Controls a <button> HTML element
Controls a <form> HTML element
Controls other HTML element not specified by
a specific HTML server control, like <body>,
<div>, <span>, etc.
Controls an <image> HTML element
Controls <input type="button">, <input
type="submit">, and <input type="reset">
HTML elements
HTML Server controls
HTML Server Control
Controls an <input type="checkbox"> HTML
Controls an <input type="file"> HTML
Controls an <input type="hidden"> HTML
Controls an <input type="image"> HTML
Controls an <input type="radio"> HTML
Controls <input type="text"> and <input
type="password"> HTML elements
HTML Server controls
HTML Server Control
Controls a <select> HTML element
Controls a <table> HTML element
Controls <td>and <th> HTML elements
Controls a <tr> HTML element
Controls a <textarea> HTML element
Controls a <select> HTML element
ASP.NET Web Server controls
•Web server controls are special ASP.NET tags
understood by the server.
•Like HTML server controls, Web server controls are also
created on the server and they require a runat="server"
attribute to work.
• Web server controls do not necessarily map to any
existing HTML elements and they may represent more
complex elements.
•The syntax for creating a Web server control is:
•<asp:control_name id="some_id" runat="server" />
ASP.NET Web Server controls
Web Server Control
iDisplays a sequence of images
Displays a push button
Displays a calendar
A day in a calendar control
Displays a check box
Creates a multi-selection check box group
Displays fields of a data source in a grid
Displays items from a data source by
using templates
Creates a drop-down list
ASP.NET Web Server controls
Web Server Control
Creates a hyperlink
Displays an image
Displays a clickable image
Displays static content which is
programmable (lets you apply styles to its
Creates a hyperlink button
Creates a single- or multi-selection dropdown list
Creates an item in a list
Displays static content which is
programmable(does not let you apply
styles to its content)
ASP.NET Web Server controls
Web Server Control
Provides a container for other controls
Reserves space for controls added by code
Creates a radio button
Creates a group of radio buttons
Creates a list in bullet format
Displays a repeated list of items bound to the
Sets the style of controls
Creates a table
ASP.NET Web Server controls
Web Server Control
Creates a table cell
Creates a table row
Creates a text box
Displays an XML file or the results of an XSL
ASP.NET Ajax Server controls
•AJAX stands for Asynchronous JavaScript and
• This is a cross platform technology which speeds
up response time.
•The AJAX server controls add script to the page
which is executed and processed by the browser.
•Like other ASP.NET server controls, AJAX server
controls have methods and event handlers
associated with them, which are processed on the
server side.
ASP.NET Ajax Server controls
•The control toolbox in the Visual Studio IDE
contains a group of controls called the 'AJAX
Ajax Extension-The ScriptManager
•The ScriptManager control is the most important
control and must be present on the page for other
controls to work.
•It has the basic syntax:
<asp:ScriptManager ID="ScriptManager1"
runat="server"> </asp:ScriptManager>
•If you create an 'Ajax Enabled site' or add an
'AJAX Web Form' from the 'Add Item' dialog box,
the web form automatically contains the script
manager control.
Ajax Extension-The ScriptManager
•The ScriptManager control takes care of the
client-side script for all the server side controls.
Ajax Extension-The UpdatePanel
•The UpdatePanel control is a container control
and derives from the Control class.
•It acts as a container for the child controls within
it and does not have its own interface.
•When a control inside it triggers a post back, the
UpdatePanel intervenes to initiate the post
asynchronously and update just that portion of the
Visual Studio .NET IDE Layout
Kashif Jalal CA-240 (072)
ASP.NET is a web application framework
developed and marketed by Microsoft to
allow programmers to build dynamic web
It allows you to use a full featured
programming language such as C# or
VB.NET to build web applications easily.
ASP.NET works on top of the HTTP
protocol, and uses the HTTP commands
and policies to set a browser-to-server
bilateral communication and cooperation.
ASP.NET is a part of Microsoft .Net
 ASP.NET applications are compiled
codes, written using the extensible and
reusable components or objects present in
.Net framework.
 These codes can use the entire hierarchy
of classes in .Net framework.
The ASP.NET application codes can be
written in any of the following languages:
Visual Basic.Net
 ASP.NET is used to produce interactive,
data-driven web applications over the
It consists of a large number of controls
such as text boxes, buttons, and labels for
assembling, configuring, and manipulating
code to create HTML pages.
ASP.NET Web Forms Model
 ASP.NET web forms extend the eventdriven model of interaction to the web
The browser submits a web form to the
web server and the server returns a full
markup page or HTML page in response.
All client side user activities are forwarded
to the server for stateful processing.
ASP.NET Web Forms Model
 The server processes the output of the
client actions and triggers the reactions.
ASP.NET framework helps in storing the
information regarding the state of the
application, which consists of:
Page state
Session state
ASP.NET Web Forms Model
 The page state is the state of the client,
i.e., the content of various input fields in the
web form.
The session state is the collective
information obtained from various pages the
user visited and worked with, i.e., the overall
session state.
Framework of ASP.NET
Common Language Runtime:
The Common Language Runtime (CLR) is
used as execution engine for .NET framework.
All the ASP.NET code is executed in the CLR.
It performs functions like security, memory
management, exception handling, thread
execution, code verification, code security.
It is used for compilation of the ASP.NET code.
The source is compiled into the intermediate
language code.
The JIT compiler coverts the IL code into
native code that is specific to the system.
Base Class Library:
The Base Class Library is the functionality
available to all the .NET framework languages.
 It provides various features like
 database connectivity
XML document manipulation
classes and interfaces that are reusable
with the CLR.
ADO.NET is used for the database operations
in .NET.
It works efficiently with
SQL Server
 XML.
The operations like accessing data from the
data source, updating and manipulating data are
performed through ADO.NET.
 Extensible Markup Language (XML) is useful
for designing the web pages in .NET
Windows Forms
The windows Forms application is used for
creating window application in .NET.
There are wide controls and designing
features available for Windows Forms.
ASP.NET Web Forms and Services
The Web Forms user to create Web based
They include web pages and several GUI
components for designing.
 It helps simultaneous addition of controls at
runtime and design time.
Web Services are used when the user needs
specific task to be executed.
They are used for creating single application
or distributed on the web.
Common Language Specification
The Common Language Specification (CLS) is
a set of language features used for developing
web application and web services.
 It ensures interoperability among applications
without the language dependency.
 It defines a subset of Common Type System
(CTS) providing objects of different languages to
interact with each other.
Visual Studio .NET
The Visual Studio .NET is used for developing
all the web and windows applications.
 The GUI interface and extensive built in class
libraries are provided in the component.
 Web Services can be developed and
deployed using Visual Studio.
Advantages of ASP.NET
The code is reduced for building application
through ASP.NET
It is server side technology, the code is
executed at the server before sending it to the
It is easy to deploy applications as the
components are not registered in the system
The applications developed are safe and
secure due to Windows authentication
Advantages of ASP.NET
The performance is better due to early binding,
just in time compilation, and code optimization
It is language independent providing user the
flexibility to develop the application
The ADO.NET used for data binding makes
the application run faster with large volume of