SlideShare a Scribd company logo
1 of 60
Introduction to ASP.NET
What is ASP.NET ?
 ASP.NET: server side technology for creating dynamic web pages using Fully Fledged
programming languages supported by .NET
 ASP.NET is a web development platform, which provides a programming model, a
comprehensive software infrastructure and various services required to build up robust
web applications for PC as well as mobile devices.
 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.
 ASP.NET application codes can be written in any of the following languages:
 C#
 Visual Basic.Net
 Jscript
 J#
Features
 Mobile web device support
 High scalability
 Better language support
 Easier configuration and deployment
 XML based components
 Event driven programming
 Dynamic update of running application
Advantages of ASP.NET
1. ASP.NET drastically reduces the amount of code required to build large
applications.
2. With built-in Windows authentication and per-application configuration, your
applications are safe and secured.
3. It provides better performance by taking advantage of early binding, just-in-
time compilation, native optimization, and caching services right out of the
box.
4. The ASP.NET framework is complemented by a rich toolbox and designer in
the Visual Studio integrated development environment. Drag-and-drop server
controls, and automatic deployment are just a few of the features this
powerful tool provides.
5. Provides simplicity as ASP.NET makes it easy to perform common tasks,
from simple form submission and client authentication to deployment and site
configuration.
6. The source code and HTML are together therefore ASP.NET pages are easy to
maintain and write. Also the source code is executed on the server. This provides
a lot of power and flexibility to the web pages.
7. All the processes are closely monitored and managed by the ASP.NET runtime, so
that if process is dead, a new process can be created in its place, which helps keep
your application constantly available to handle requests.
8. It is purely server-side technology so, ASP.NET code executes on the server
before it is sent to the browser.
9. Being language-independent, it allows you to choose the language that best
applies to your application or partition your application across many languages.
10. ASP.NET makes for easy deployment. There is no need to register components
because the configuration information is built-in.
11. The Web server continuously monitors the pages, components and applications
running on it. If it notices any memory leaks, infinite loops, other illegal
activities, it immediately destroys those activities and restarts itself.
12. Easily works with ADO.NET using data-binding and page formatting features. It
is an application which runs faster and counters large volumes of users without
having performance problems
Difference between ASP and ASP.NET
1. ASP is interpreted, ASP.NET is compiled.
2. Classic ASP uses a technology called ADO to connect and work with
databases. ASP.NET uses the ADO.NET technology
3. ASP has Mixed HTML and coding logic where in asp.net html and
coding part are separated by code behind files.
4. ASP.NET purely object oriented whereas ASP is partially object
oriented.
5. For ASP No in-built support for XML whereas in ASP.NET full XML
Support for easy data exchange.
6. In Asp Error handling is very poor where in asp.net full proof error
handling is possible
7. ASP has no in built validation control. Meaning that validating page is
difficult for developers.Asp.net has in built rich validation set.
8. No built in support for XML in ASP but in asp.net it is.
9. Limited session and application state management in ASP but in asp.net it
is complete.
LIFE CYCLE
 ASP.NET life cycle specifies how:
 ASP.NET processes pages to produce dynamic output
 The application and its pages are instantiated and processed
 ASP.NET compiles the pages dynamically
 ASP.NET life cycle could be divided into two groups:
 Application Life Cycle
 Page Life Cycle
ASP.NET Application Life Cycle
The application life cycle has the following stages:
1. User makes a request for accessing application resource, a page. Browser
sends this request to the web server.
2. A unified pipeline receives the first request and the following events take
place:
i. An object of the class ApplicationManager is created.
ii. An object of the class HostingEnvironment is created to provide
information regarding the resources.
iii. Top level items in the application are compiled.
3. Response objects are created. The application objects such as
HttpContext, HttpRequest and HttpResponse are created and initialized.
4. An instance of the HttpApplication object is created and assigned to the
request.
5. The request is processed by the HttpApplication class. Different events
are raised by this class for processing the request.
ASP.NET Page Life Cycle
Page life cycle phases are:
 Initialization
 Instantiation of the controls on the page
 Restoration and maintenance of the state
 Execution of the event handler codes
 Page rendering
ASP.NET Page Life Cycle
Following are the different stages of an ASP.NET page:
 Page request
When ASP.NET gets a page request, it decides whether to parse and
compile the page, or there would be a cached version of the page;
accordingly the response is sent.
 Starting of page life cycle
At this stage, the Request and Response objects are set. If the request is an
old request or post back, the IsPostBack property of the page is set to true.
The UICulture property of the page is also set.
 Page initialization
At this stage, the controls on the page are assigned unique ID by setting the
UniqueID property and the themes are applied. For a new request, postback
data is loaded and the control properties are restored to the view-state
values.
 Page load
At this stage, control properties are set using the view state and control state
values.
 Validation
Validate method of the validation control is called and on its successful
execution, the IsValid property of the page is set to true.
 Postback event handling.
If the request is a postback (old request), the related event handler is
invoked.
 Page rendering
At this stage, view state for the page and all controls are saved. The page
calls the Render method for each control and the output of rendering is
written to the OutputStream class of the Response property of Page.
 Unload
The rendered page is sent to the client and page properties, such as
Response and Request, are unloaded and all cleanup done.
ASP.NET Page Life Cycle Events
At each stage of the page life cycle, the page raises some events, which
could be coded. An event handler is basically a function or subroutine,
bound to the event, using declarative attributes such as Onclick or handle.
Following are the page life cycle events:
 PreInit -PreInit is the first event in page life cycle. It checks the IsPostBack
property and determines whether the page is a postback. It sets the themes
and master pages, creates dynamic controls, and gets and sets profile
property values. This event can be handled by overloading the OnPreInit
method or creating a Page_PreInit handler.
 Init -Init event initializes the control property and the control tree is built.
This event can be handled by overloading the OnInit method or creating a
Page_Init handler.
 InitComplete -InitComplete event allows tracking of view state. All the
controls turn on view-state tracking.
 LoadViewState-LoadViewState event allows loading view state
information into the controls.
 LoadPostData-During this phase, the contents of all the input fields
are defined with the <form> tag are processed.
 PreLoad -PreLoad occurs before the post back data is loaded in the
controls. This event can be handled by overloading the OnPreLoad method
or creating a Page_PreLoad handler.
 LoadThe Load event is raised for the page first and then recursively for all
child controls. The controls in the control tree are created. This event can be
handled by overloading the OnLoad method or creating a Page_Load
handler.
 LoadComplete -The loading process is completed, control event handlers
are run, and page validation takes place. This event can be handled by
overloading the OnLoadComplete method or creating a
Page_LoadComplete handler.
 PreRender-The PreRender event occurs just before the output is rendered.
By handling this event, pages and controls can perform any updates before
the output is rendered.
 PreRenderComplete-As the PreRender event is recursively fired for all
child controls, this event ensures the completion of the pre-rendering phase.
 SaveStateComplete-State of control on the page is saved. Personalization,
control state and view state information is saved. The HTML markup is
generated. This stage can be handled by overriding the Render method or
creating a Page_Render handler.
 UnLoad -The UnLoad phase is the last phase of the page life cycle. It raises
the UnLoad event for all controls recursively and lastly for the page itself.
Final cleanup is done and all resources and references, such as database
connections, are freed. This event can be handled by modifying the
OnUnLoad method or creating a Page_UnLoad handler.
ASP.NET
 Visual Studio .NET is a developer application used to create ASP.NET Web
applications
 There are two main types of Web resources created with ASP.NET
applications
 WebForms are ASP.NET pages within an ASP.NET application
 Web Services are ASP.NET Web pages that contain publicly exposed
code so that other applications can interact with them.Web Services are
identified with the file extension .asmx
WebForms
 The ASP.NET WebForm is separated into two logical areas:
 The HTML template
 A collection of code behind the WebForm
 The HTML template
 Contains the design layout, content, and the controls
 Creates the user interface, or presentation layer
 Instructs the browser how to format the Web page
 Is created using a combination of HTML controls, HTML Server
controls, Mobile Controls, and ASP.NET controls
The Code Behind
 Server programs are written in a separate file known as the
code behind the page
 By separating the programming logic and presentation layer,
the application becomes easier to maintain
 Only Server controls can interact with the code behind the
page
 Written in any ASP.NET compatible language such as
Visual Basic .NET, C#, Perl, or Java
 Filename is the same as the WebForm filename
 Add a file extension that identifies the language
 Visual Basic .NET use .vb (mypage.aspx.vb)
 C# use .cs (mypage.aspx.cs)
STARTING A NEW WEBSITE
 Open Visual Web Developer 2010 and in the file menu select the new
website option from the dropdown menu or on the start page.
 When the new website dialogue box appears, select installed
templates and then select visual C# from the dropdown list to set
the programing language. Visual studio comes with two pre-
installed “code-behind” programming languages C# and Visual
Basic.
 Select Empty ASP.NET Website from the list in the center. This will
start your project without the default webpage. When starting a new
website, visual studio gives you the option of either creating a blank
website or opening a pre-structured website that has a default style
and master page already applied to it.
CREATING A BASIC WEB PAGE
 In the solution explorer, right click the name of the
website (Example:C:……website1) and select Add
New Item from the list.
 When the Add New Item display opens, select Web
Form from the installed templates list. Take look at the
installed templates list. These are all of the pre-
installed templates that can be used to create dynamic
web applications.
 An ASP.NET page is also a server side file saved with
the .aspx extension. It is modular in nature and can be
divided into the following core sections:
 Page Directives
 Code Section
 Page Layout
Page Directives
 The page directives set up the environment for the
page to run. The @Page directive defines page-specific
attributes used by ASP.NET page parser and compiler.
Page directives specify how the page should be
processed, and which assumptions need to be taken
about the page.
 It allows importing namespaces, loading assemblies,
and registering new controls with custom tag names
and namespace prefixes.
Code Section
 The code section provides the handlers for the page
and control events along with other functions
required.
 The code section or the code behind file provides all
event handler routines, and other functions used by
the developer. The page code could be precompiled
and deployed in the form of a binary assembly.
Page Layout
 The page layout provides the interface of the page. It contains the server
controls, text, inline JavaScript, and HTML tags.
 The following code snippet provides a sample ASP.NET page explaining
Page directives, code section and page layout written in C#:
CONTROLS
 Controls are small building blocks of the graphical user interface, which
include text boxes,buttons, check boxes, list boxes, labels, and numerous
other tools. Using these tools, the users can enter data, make selections and
indicate their preferences.
 Controls are also used for structural jobs, like validation, data access,
security, creating master pages, and data manipulation.
 ASP.NET uses five types of web controls:
• HTML controls
• HTML Server controls
• ASP.NET Server controls
• ASP.NET Ajax Server controls
• User controls and custom controls
 The HTML server controls are basically the standard HTML controls
enhanced to enable server side processing. The HTML controls such as the
header tags, anchor tags, and input elements are not processed by the server
but are sent to the browser for display.
ASP.NET HTML Server Controls
 ASP.NET provides a way to work with HTML Server controls on the server
side; programming with a set of controls collectively is called HTML
Controls.
 These controls are grouped together in the Visual Studio Toolbox in the the
HTML Control tab. The markup of the controls are similar to the HTML
control.
 These controls are basically the original HTML controls but enhanced to
enable server side processing.
 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. This attribute 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. The runat="server" attribute indicates that the form
should be processed on the server. It also indicates that the enclosed controls
can be accessed by server scripts.
The System.Web.UI.HtmlControls.HtmlControl base class contains all of
the common properties. HTML server controls derive from this class.
 For example, consider the HTML input control:
The following table describes the
HTML server controls:
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.
 However, Web server controls do not necessarily map to any existing
HTML elements and they may represent more complex elements.
 Mostly all Web Server controls inherit from a common base class,
namely the WebControlclass defined in
the System.Web.UI.WebControls namespace.
 The syntax for creating a Web server control is:
The following table describes the WEB
server controls:
ASP.NET Validation Server Controls
 After you create a web form, you should make sure that mandatory fields of
the form elements such as login name and password are not left blank; data
inserted is correct and is within the specified range. Validation is the method
of scrutinizing (observing) that the user has entered the correct values in
input fields.
 A Validation server control is used to validate the data of an input control. If
the data does not pass validation, it will display an error message to the user.
 In ASP. NET you can use ASP. NET Validation Controls while creating the
form and specify what ASP. NET Validation Controls you want to use and to
which server control you want bind this.
 Validation Controls are derived from a common base class and share a
common set of properties and methods. You just have to drag and drop the
ASP. NET Validation Control in the web form and write one line of code to
describe its functionality.
 This reduces the developer time from writing JavaScript for each type of
validation. Moreover, through ASP. NET Validation Controls if any invalid
data is entered the browser itself detects the error on the client side and
displays the error without requesting the server. This is another advantage
because it reduces the server load.
Some Server Validation controls are:
Server Controls
 HTML Server controls are similar to the HTML controls, except
they are processed by the server
 Add runat = "server" to the HTML control to transform it into an
HTML Server control
 HTML control:
<input type="text">
 HTML Server control:
<input type="text" runat="server"/>
<input type=”radio” runat=”server” value=”Yes”/> Yes
 Server-side programs can interact with the control before it is
rendered as a plain HTML control and sent to the browser
ASP.NET Controls
 ASP.NET form controls will create the HTML code
 ASP.NET Server controls are organized as:
 ASP.NET Form Controls
 Data Validation Controls
 User Controls
 Mobile Controls
 ASP.NET controls are usually identified with the prefix asp:
followed by the name of the control
 ASP.NET button:
<asp:Button id="ShowBtn" runat="server"
Text="Show the message." />
HTML Server Vs ASP.NET Server
Controls
 ASP.NET form controls can interact with client-side events such as
when the user clicks on a button
 When the event occurs, ASP.NET can trigger a script to run on
the server
 ASP.NET form controls also have different properties than their
HTML server control counterparts
 HTML Server label control
 Message1.InnerHTML = "Product 1"
 ASP server label control
 Message2.Text = "Product 2"
User Controls
 User controls are external files that can be included within another
WebForm
 User controls allow you to reuse code across multiple files
 For example, you can create a user control that displays the a
navigation bar
 You can use this control on the home page; they are often used for
creating self-contained code, headers, menus, and footers
 User controls replace the functionality of ASP server-side include
pages
 They are identified with the file extension .asmx
Other ASP.NET Server Controls
 Data validation controls
 A series of controls that validate form data without extensive
JavaScript programming
 Mobile controls
 A series of controls that provide form functionality within
wireless and mobile devices
 Literal controls
 Page content that is not assigned to a specific HTML control
such as a combination of HTML tags and text to the browser
Server Controls within
Visual Studio .NET
 In Visual Studio
.NET most of the
ASP.NET Server
controls are located
on the Web Forms
tab in the toolbox
Server controls with Visual Studio.NET
Code Behind file
 The location of the code behind the page is determined via a property
that is set on the first line in the page using the @Page directive
<%@ Page Language="vb" Codebehind="WebForm1.vb"
Inherits=“MyFirstApp.WebForm1"%>
 The @Page directive allows you to set the default properties for the
entire page such as the default language
 The CodeBehind property identifies the path and filename of the code
behind file
 The Inherits property indicates that the code behind the page inherits
the page class
 This page class contains the compiled code for this page
Compiling the Page Class
 The compiled code behind the page is the class definition for the
page
 A class is a named logical grouping of code
 The class definition contains the functions, methods, and
properties that belong to that class
 In Visual Studio .NET the process of compiling a class is called
building
 When you build the application, you compile the code into an
executable file
 Visual Studio .NET compiles the code behind the page into an
executable file and places the file in the bin directory
Page Class Events
 The Page Class consists of a variety of methods, functions,
and properties that can be accessed within the code behind the
page
 The first time a page is requested by a client, a series of page
events occurs
 The first page event is the Page_Init event which initializes
the page control hierarchy
 The Page_Load event loads any server controls into memory
and occurs every time the page is executed
Page class events
 Page_init
 Page_load
 Server_Controls
 Page_prerender
 Page_Unload
Web Services
 Web Services also provide a means to expose .NET
functionality on the web but Web Services expose
functionality via XML and SOAP (cf: function calls
over the web)
Web Services
 If your business partner is Course Technology
and you want to query that company’s product
catalog from your Web site, you could:
 Post a link
 Scrape a Web site (use a program to view a Web site and
capture the source code)
 Provide a Web Service to their catalog application
 Web Services are used to create business-to-
business applications
 Web Services allow you to expose part or all of your
programs over the Internet. The Web Service source file
has the extension .asmx
 A public registry known as UDDI contains registered
public Web Services. Third party Web Services are
available at http://www.xmethods.com
How ASP.NET works
 When .NET is installed, IIS is configured to look for
files with the .aspx extension and to use the
ASP.NET module (aspnet_isapi.dll) to handle them.
 ASP.NET parses the .aspx file and arranges it in a
predefined class definition and generates an asp.net
page object.
 The page object generates html that is sent back to
IIS and then the browser.
 NOTE: only .aspx files are parsed (if it is pure html
don’t save it as an aspx file as it will slow down the
server.
ASP.NET samples
 Page directives: <%@ page language = “VB”
debug="true" trace="true“ %>
 <script language = “VB” runat=“server”> VB.NET
code declarations ……….. </script>
 Message.aspx
<html>
<head> <title>Inserting ASP.NET code Example</title> </head>
<body>
Line1: First HTML Line<br />
Line2: Second HTML Line<br />
Line3: Third HTML Line<br />
</body>
</html>
 Note this has no asp code so better to use .html extension
 Message2.aspx
<script language="VB" runat="server">
Sub Page_Load()
Response.Write ("First ASP.NET Line<br />")
Response.Write ("Second ASP.NET Line<br />")
Response.Write ("Third ASP.NET Line<br />")
End Sub
</script>
<html> <head> <title>Inserting ASP.NET code Example</TITLE>
</head>
<body>
Line1: First HTML Line<br />
Line2: Second HTML Line<br />
Line3: Third HTML Line<br />
</body>
</html>
 Message3.aspx
html>
<head><title>Inserting ASP.NET code Example</title></head>
<body>
Line1: First HTML Line<br />
Line2: Second HTML Line<br />
Line3: Third HTML Line<br />
<script language="VB" runat="server">
Sub Page_Load()
Response.Write ("First ASP.NET Line<br />")
Response.Write ("Second ASP.NET Line<br />")
Response.Write ("Third ASP.NET Line<br />")
End Sub
</script>
</body>
</html>
Render or inline code block –
interweave1.aspx
<html>
<head>
<title>Interweaving ASP.NET code and HTML Example</title>
</head>
<body>
Line1: First HTML Line<br />
<% Response.Write ("First ASP.NET Line<br />") %>
Line2: Second HTML Line<br />
<% Response.Write ("Second ASP.NET Line<br />") %>
Line3: Third HTML Line<br />
<% Response.Write ("Third ASP.NET Line<br />") %>
</body>
</html>
NOT RECOMMENDED.
Interweave2.aspx A Server
control
script language="VB" runat="server">
Sub Page_Load()
Message.Text="The ASP.NET line"
End Sub
</script>
<html>
<head> <title>Inserting ASP.NET code Example</TITLE>
</head>
<body>
First HTML Line<br/>
<asp:label id=Message runat="server"/> <br />
Second HTML Line<br/>
</body>
Web application project files
AssemblyInfo.vb Info about the compiled project file stored in
/bin and named project.dll
Global.asax Event handler commands visible to all web
forms in a project
Global.asax.resx Define application resources such as text
strings, images. Can change without
recompiling project.
Global.asax.vb Asp.net code for application events eg
session.start
Project.sln Stores links to all project files
Project.suo VS.NET IDE configuration info for the proj.
Project.vbproj Configuration and build settings for project
files.
Web application project files
cont.
Project.vbproj.webinfo URL to project web server
Project.vsdisco Enables search for web services
Styles.css Project style sheet
Web.config Project and folder configuration information
Webform.aspx Web form .aspx file;Html
Webform.aspx.resx Resources in corresponding web form
Webform.aspx.vb Code written for the form (code behind)
Binproject.dll Compiled project output file (assembly)
Binproject.pdb Debugging information used by developer
Viewing the Assembly
 Create a simple class, compile the class into an
assembly, then view the class using the IL
Disassembler
 Open Notepad and type the code shown:
' hello.vb - displays hello world
' Created 06/01/2002
Imports System
Public Module Hello
Sub Main()
Dim s1 As String = "1 - Hello World"
Console.WriteLine(s1)
End Sub
End Module
' Run this at the command line
' vbc hello.vb
Using the ILDASM to
View the Assembly and
Classes
Using the ILDASM to view the assembly and classes
Examples
 quickstart – webforms
 Intro4 shows VIEWSTATE
 Intro6 shows a click event
 Intro7 shows a usercontrol with a calander
 Intro8 shows a db connection
 Intro9 & 10 show asp.net templates
 Intro11shows validation controls
 Intro13 shows code behind pages
 Server directives eg trace and debug
 trace
The lab environment.
 Each machine is set up to be an IIS server –
http://localhost:1900/…..
 You create your web projects with Visual Studio.Net.
VS.NET will create a subdirectory in
c:/inetpub/wwwroot for your project. You must copy
this subdirectory when moving to another machine or
home.
 URL
 http://localhost:1900/MyfirstApp/homepage.aspx
 Alternative to VS.Net is webmatrix
 Some samples on another machine
 http://interdev.csse.monash.edu.au/cse2030/ Interdev is
not accessible outside the Monash network.
ASP.NET Vs PHP
Feature PHP ASP.NET
HTML Yes Yes
CSS Yes Yes
‘php Templates’ Yes UserControls
ServerControls
(buttons,grids etc)
No Yes
Javascript Yes Yes + Validation controls
Database Conn Yes Yes
Cookies & Sessions Yes Yes
VIEWSTATE No Yes
POSTBACK No Yes

More Related Content

What's hot (20)

Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
Controls
ControlsControls
Controls
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
IIS
IISIIS
IIS
 
Java swing
Java swingJava swing
Java swing
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Asynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & PromisesAsynchronous JavaScript Programming with Callbacks & Promises
Asynchronous JavaScript Programming with Callbacks & Promises
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
VB.net
VB.netVB.net
VB.net
 
VB Script
VB ScriptVB Script
VB Script
 
Active Server Page(ASP)
Active Server Page(ASP)Active Server Page(ASP)
Active Server Page(ASP)
 
Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Java beans
Java beansJava beans
Java beans
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
Servlets
ServletsServlets
Servlets
 
Control Structures In Php 2
Control Structures In Php 2Control Structures In Php 2
Control Structures In Php 2
 

Similar to Asp.net control

Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with spparallelminder
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in detailsAyesha Khan
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Ayesha Khan
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asppriya Nithya
 
Asp.net life cycle
Asp.net life cycleAsp.net life cycle
Asp.net life cycleIrfaan Khan
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02santoshkjogalekar
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depthsonia merchant
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1Neeraj Mathur
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.NetHitesh Santani
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 
Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle eventsTrushant parkar
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singhimdurgesh
 
Page life cycle
Page life cyclePage life cycle
Page life cycleanil4691
 
Page life cycle IN ASP.NET
Page life cycle IN ASP.NETPage life cycle IN ASP.NET
Page life cycle IN ASP.NETSireesh K
 

Similar to Asp.net control (20)

Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in details
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?
 
ASP.NET - Life cycle of asp
ASP.NET - Life cycle of aspASP.NET - Life cycle of asp
ASP.NET - Life cycle of asp
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
 
Asp.net life cycle
Asp.net life cycleAsp.net life cycle
Asp.net life cycle
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02Aspnetpagelifecycle 101129103702-phpapp02
Aspnetpagelifecycle 101129103702-phpapp02
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depth
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
ASP.NET Lecture 2
ASP.NET Lecture 2ASP.NET Lecture 2
ASP.NET Lecture 2
 
Aspnet life cycle events
Aspnet life cycle eventsAspnet life cycle events
Aspnet life cycle events
 
Asp.net By Durgesh Singh
Asp.net By Durgesh SinghAsp.net By Durgesh Singh
Asp.net By Durgesh Singh
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
 
Page life cycle
Page life cyclePage life cycle
Page life cycle
 
Page life cycle IN ASP.NET
Page life cycle IN ASP.NETPage life cycle IN ASP.NET
Page life cycle IN ASP.NET
 

More from Paneliya Prince (20)

140120107044 ins ala.ppt
140120107044 ins ala.ppt140120107044 ins ala.ppt
140120107044 ins ala.ppt
 
To create a web service
To create a web serviceTo create a web service
To create a web service
 
Session and state management
Session and state managementSession and state management
Session and state management
 
Master pages
Master pagesMaster pages
Master pages
 
Master page
Master pageMaster page
Master page
 
Managing states
Managing statesManaging states
Managing states
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
Grid view control
Grid view controlGrid view control
Grid view control
 
Asp.net validation
Asp.net validationAsp.net validation
Asp.net validation
 
Wt oep visiting card
Wt oep visiting cardWt oep visiting card
Wt oep visiting card
 
SE OEP online car service booking
SE OEP online car service bookingSE OEP online car service booking
SE OEP online car service booking
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
 
processing control input
processing control inputprocessing control input
processing control input
 
static dictionary technique
static dictionary techniquestatic dictionary technique
static dictionary technique
 
Ajava oep
Ajava oep Ajava oep
Ajava oep
 
Ajava oep shopping application
Ajava oep shopping applicationAjava oep shopping application
Ajava oep shopping application
 
creating jdbc connection
creating jdbc connectioncreating jdbc connection
creating jdbc connection
 
DCDR
DCDRDCDR
DCDR
 
static dictionary
static dictionarystatic dictionary
static dictionary
 
ADO.net control
ADO.net controlADO.net control
ADO.net control
 

Recently uploaded

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 

Recently uploaded (20)

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 

Asp.net control

  • 1. Introduction to ASP.NET What is ASP.NET ?  ASP.NET: server side technology for creating dynamic web pages using Fully Fledged programming languages supported by .NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required to build up robust web applications for PC as well as mobile devices.  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.  ASP.NET application codes can be written in any of the following languages:  C#  Visual Basic.Net  Jscript  J#
  • 2. Features  Mobile web device support  High scalability  Better language support  Easier configuration and deployment  XML based components  Event driven programming  Dynamic update of running application
  • 3. Advantages of ASP.NET 1. ASP.NET drastically reduces the amount of code required to build large applications. 2. With built-in Windows authentication and per-application configuration, your applications are safe and secured. 3. It provides better performance by taking advantage of early binding, just-in- time compilation, native optimization, and caching services right out of the box. 4. The ASP.NET framework is complemented by a rich toolbox and designer in the Visual Studio integrated development environment. Drag-and-drop server controls, and automatic deployment are just a few of the features this powerful tool provides. 5. Provides simplicity as ASP.NET makes it easy to perform common tasks, from simple form submission and client authentication to deployment and site configuration.
  • 4. 6. The source code and HTML are together therefore ASP.NET pages are easy to maintain and write. Also the source code is executed on the server. This provides a lot of power and flexibility to the web pages. 7. All the processes are closely monitored and managed by the ASP.NET runtime, so that if process is dead, a new process can be created in its place, which helps keep your application constantly available to handle requests. 8. It is purely server-side technology so, ASP.NET code executes on the server before it is sent to the browser. 9. Being language-independent, it allows you to choose the language that best applies to your application or partition your application across many languages. 10. ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in. 11. The Web server continuously monitors the pages, components and applications running on it. If it notices any memory leaks, infinite loops, other illegal activities, it immediately destroys those activities and restarts itself. 12. Easily works with ADO.NET using data-binding and page formatting features. It is an application which runs faster and counters large volumes of users without having performance problems
  • 5. Difference between ASP and ASP.NET 1. ASP is interpreted, ASP.NET is compiled. 2. Classic ASP uses a technology called ADO to connect and work with databases. ASP.NET uses the ADO.NET technology 3. ASP has Mixed HTML and coding logic where in asp.net html and coding part are separated by code behind files. 4. ASP.NET purely object oriented whereas ASP is partially object oriented. 5. For ASP No in-built support for XML whereas in ASP.NET full XML Support for easy data exchange. 6. In Asp Error handling is very poor where in asp.net full proof error handling is possible 7. ASP has no in built validation control. Meaning that validating page is difficult for developers.Asp.net has in built rich validation set. 8. No built in support for XML in ASP but in asp.net it is. 9. Limited session and application state management in ASP but in asp.net it is complete.
  • 6. LIFE CYCLE  ASP.NET life cycle specifies how:  ASP.NET processes pages to produce dynamic output  The application and its pages are instantiated and processed  ASP.NET compiles the pages dynamically  ASP.NET life cycle could be divided into two groups:  Application Life Cycle  Page Life Cycle
  • 7. ASP.NET Application Life Cycle The application life cycle has the following stages: 1. User makes a request for accessing application resource, a page. Browser sends this request to the web server. 2. A unified pipeline receives the first request and the following events take place: i. An object of the class ApplicationManager is created. ii. An object of the class HostingEnvironment is created to provide information regarding the resources. iii. Top level items in the application are compiled. 3. Response objects are created. The application objects such as HttpContext, HttpRequest and HttpResponse are created and initialized. 4. An instance of the HttpApplication object is created and assigned to the request. 5. The request is processed by the HttpApplication class. Different events are raised by this class for processing the request.
  • 8. ASP.NET Page Life Cycle Page life cycle phases are:  Initialization  Instantiation of the controls on the page  Restoration and maintenance of the state  Execution of the event handler codes  Page rendering
  • 9. ASP.NET Page Life Cycle Following are the different stages of an ASP.NET page:  Page request When ASP.NET gets a page request, it decides whether to parse and compile the page, or there would be a cached version of the page; accordingly the response is sent.  Starting of page life cycle At this stage, the Request and Response objects are set. If the request is an old request or post back, the IsPostBack property of the page is set to true. The UICulture property of the page is also set.  Page initialization At this stage, the controls on the page are assigned unique ID by setting the UniqueID property and the themes are applied. For a new request, postback data is loaded and the control properties are restored to the view-state values.
  • 10.  Page load At this stage, control properties are set using the view state and control state values.  Validation Validate method of the validation control is called and on its successful execution, the IsValid property of the page is set to true.  Postback event handling. If the request is a postback (old request), the related event handler is invoked.  Page rendering At this stage, view state for the page and all controls are saved. The page calls the Render method for each control and the output of rendering is written to the OutputStream class of the Response property of Page.  Unload The rendered page is sent to the client and page properties, such as Response and Request, are unloaded and all cleanup done.
  • 11. ASP.NET Page Life Cycle Events At each stage of the page life cycle, the page raises some events, which could be coded. An event handler is basically a function or subroutine, bound to the event, using declarative attributes such as Onclick or handle. Following are the page life cycle events:  PreInit -PreInit is the first event in page life cycle. It checks the IsPostBack property and determines whether the page is a postback. It sets the themes and master pages, creates dynamic controls, and gets and sets profile property values. This event can be handled by overloading the OnPreInit method or creating a Page_PreInit handler.  Init -Init event initializes the control property and the control tree is built. This event can be handled by overloading the OnInit method or creating a Page_Init handler.  InitComplete -InitComplete event allows tracking of view state. All the controls turn on view-state tracking.  LoadViewState-LoadViewState event allows loading view state information into the controls.  LoadPostData-During this phase, the contents of all the input fields are defined with the <form> tag are processed.
  • 12.  PreLoad -PreLoad occurs before the post back data is loaded in the controls. This event can be handled by overloading the OnPreLoad method or creating a Page_PreLoad handler.  LoadThe Load event is raised for the page first and then recursively for all child controls. The controls in the control tree are created. This event can be handled by overloading the OnLoad method or creating a Page_Load handler.  LoadComplete -The loading process is completed, control event handlers are run, and page validation takes place. This event can be handled by overloading the OnLoadComplete method or creating a Page_LoadComplete handler.  PreRender-The PreRender event occurs just before the output is rendered. By handling this event, pages and controls can perform any updates before the output is rendered.  PreRenderComplete-As the PreRender event is recursively fired for all child controls, this event ensures the completion of the pre-rendering phase.
  • 13.  SaveStateComplete-State of control on the page is saved. Personalization, control state and view state information is saved. The HTML markup is generated. This stage can be handled by overriding the Render method or creating a Page_Render handler.  UnLoad -The UnLoad phase is the last phase of the page life cycle. It raises the UnLoad event for all controls recursively and lastly for the page itself. Final cleanup is done and all resources and references, such as database connections, are freed. This event can be handled by modifying the OnUnLoad method or creating a Page_UnLoad handler.
  • 14. ASP.NET  Visual Studio .NET is a developer application used to create ASP.NET Web applications  There are two main types of Web resources created with ASP.NET applications  WebForms are ASP.NET pages within an ASP.NET application  Web Services are ASP.NET Web pages that contain publicly exposed code so that other applications can interact with them.Web Services are identified with the file extension .asmx
  • 15. WebForms  The ASP.NET WebForm is separated into two logical areas:  The HTML template  A collection of code behind the WebForm  The HTML template  Contains the design layout, content, and the controls  Creates the user interface, or presentation layer  Instructs the browser how to format the Web page  Is created using a combination of HTML controls, HTML Server controls, Mobile Controls, and ASP.NET controls
  • 16. The Code Behind  Server programs are written in a separate file known as the code behind the page  By separating the programming logic and presentation layer, the application becomes easier to maintain  Only Server controls can interact with the code behind the page  Written in any ASP.NET compatible language such as Visual Basic .NET, C#, Perl, or Java  Filename is the same as the WebForm filename  Add a file extension that identifies the language  Visual Basic .NET use .vb (mypage.aspx.vb)  C# use .cs (mypage.aspx.cs)
  • 17. STARTING A NEW WEBSITE  Open Visual Web Developer 2010 and in the file menu select the new website option from the dropdown menu or on the start page.  When the new website dialogue box appears, select installed templates and then select visual C# from the dropdown list to set the programing language. Visual studio comes with two pre- installed “code-behind” programming languages C# and Visual Basic.  Select Empty ASP.NET Website from the list in the center. This will start your project without the default webpage. When starting a new website, visual studio gives you the option of either creating a blank website or opening a pre-structured website that has a default style and master page already applied to it.
  • 18.
  • 19. CREATING A BASIC WEB PAGE  In the solution explorer, right click the name of the website (Example:C:……website1) and select Add New Item from the list.  When the Add New Item display opens, select Web Form from the installed templates list. Take look at the installed templates list. These are all of the pre- installed templates that can be used to create dynamic web applications.
  • 20.
  • 21.
  • 22.  An ASP.NET page is also a server side file saved with the .aspx extension. It is modular in nature and can be divided into the following core sections:  Page Directives  Code Section  Page Layout
  • 23. Page Directives  The page directives set up the environment for the page to run. The @Page directive defines page-specific attributes used by ASP.NET page parser and compiler. Page directives specify how the page should be processed, and which assumptions need to be taken about the page.  It allows importing namespaces, loading assemblies, and registering new controls with custom tag names and namespace prefixes.
  • 24. Code Section  The code section provides the handlers for the page and control events along with other functions required.  The code section or the code behind file provides all event handler routines, and other functions used by the developer. The page code could be precompiled and deployed in the form of a binary assembly.
  • 25. Page Layout  The page layout provides the interface of the page. It contains the server controls, text, inline JavaScript, and HTML tags.  The following code snippet provides a sample ASP.NET page explaining Page directives, code section and page layout written in C#:
  • 26.
  • 27. CONTROLS  Controls are small building blocks of the graphical user interface, which include text boxes,buttons, check boxes, list boxes, labels, and numerous other tools. Using these tools, the users can enter data, make selections and indicate their preferences.  Controls are also used for structural jobs, like validation, data access, security, creating master pages, and data manipulation.  ASP.NET uses five types of web controls: • HTML controls • HTML Server controls • ASP.NET Server controls • ASP.NET Ajax Server controls • User controls and custom controls  The HTML server controls are basically the standard HTML controls enhanced to enable server side processing. The HTML controls such as the header tags, anchor tags, and input elements are not processed by the server but are sent to the browser for display.
  • 28. ASP.NET HTML Server Controls  ASP.NET provides a way to work with HTML Server controls on the server side; programming with a set of controls collectively is called HTML Controls.  These controls are grouped together in the Visual Studio Toolbox in the the HTML Control tab. The markup of the controls are similar to the HTML control.  These controls are basically the original HTML controls but enhanced to enable server side processing.  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. This attribute indicates that the element should be treated as a server control.
  • 29. Note:  All HTML server controls must be within a <form> tag with the runat="server" attribute. The runat="server" attribute indicates that the form should be processed on the server. It also indicates that the enclosed controls can be accessed by server scripts. The System.Web.UI.HtmlControls.HtmlControl base class contains all of the common properties. HTML server controls derive from this class.  For example, consider the HTML input control:
  • 30. The following table describes the HTML server controls:
  • 31. 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.  However, Web server controls do not necessarily map to any existing HTML elements and they may represent more complex elements.  Mostly all Web Server controls inherit from a common base class, namely the WebControlclass defined in the System.Web.UI.WebControls namespace.  The syntax for creating a Web server control is:
  • 32. The following table describes the WEB server controls:
  • 33. ASP.NET Validation Server Controls  After you create a web form, you should make sure that mandatory fields of the form elements such as login name and password are not left blank; data inserted is correct and is within the specified range. Validation is the method of scrutinizing (observing) that the user has entered the correct values in input fields.  A Validation server control is used to validate the data of an input control. If the data does not pass validation, it will display an error message to the user.  In ASP. NET you can use ASP. NET Validation Controls while creating the form and specify what ASP. NET Validation Controls you want to use and to which server control you want bind this.  Validation Controls are derived from a common base class and share a common set of properties and methods. You just have to drag and drop the ASP. NET Validation Control in the web form and write one line of code to describe its functionality.  This reduces the developer time from writing JavaScript for each type of validation. Moreover, through ASP. NET Validation Controls if any invalid data is entered the browser itself detects the error on the client side and displays the error without requesting the server. This is another advantage because it reduces the server load.
  • 34. Some Server Validation controls are:
  • 35.
  • 36. Server Controls  HTML Server controls are similar to the HTML controls, except they are processed by the server  Add runat = "server" to the HTML control to transform it into an HTML Server control  HTML control: <input type="text">  HTML Server control: <input type="text" runat="server"/> <input type=”radio” runat=”server” value=”Yes”/> Yes  Server-side programs can interact with the control before it is rendered as a plain HTML control and sent to the browser
  • 37. ASP.NET Controls  ASP.NET form controls will create the HTML code  ASP.NET Server controls are organized as:  ASP.NET Form Controls  Data Validation Controls  User Controls  Mobile Controls  ASP.NET controls are usually identified with the prefix asp: followed by the name of the control  ASP.NET button: <asp:Button id="ShowBtn" runat="server" Text="Show the message." />
  • 38. HTML Server Vs ASP.NET Server Controls  ASP.NET form controls can interact with client-side events such as when the user clicks on a button  When the event occurs, ASP.NET can trigger a script to run on the server  ASP.NET form controls also have different properties than their HTML server control counterparts  HTML Server label control  Message1.InnerHTML = "Product 1"  ASP server label control  Message2.Text = "Product 2"
  • 39. User Controls  User controls are external files that can be included within another WebForm  User controls allow you to reuse code across multiple files  For example, you can create a user control that displays the a navigation bar  You can use this control on the home page; they are often used for creating self-contained code, headers, menus, and footers  User controls replace the functionality of ASP server-side include pages  They are identified with the file extension .asmx
  • 40. Other ASP.NET Server Controls  Data validation controls  A series of controls that validate form data without extensive JavaScript programming  Mobile controls  A series of controls that provide form functionality within wireless and mobile devices  Literal controls  Page content that is not assigned to a specific HTML control such as a combination of HTML tags and text to the browser
  • 41. Server Controls within Visual Studio .NET  In Visual Studio .NET most of the ASP.NET Server controls are located on the Web Forms tab in the toolbox Server controls with Visual Studio.NET
  • 42. Code Behind file  The location of the code behind the page is determined via a property that is set on the first line in the page using the @Page directive <%@ Page Language="vb" Codebehind="WebForm1.vb" Inherits=“MyFirstApp.WebForm1"%>  The @Page directive allows you to set the default properties for the entire page such as the default language  The CodeBehind property identifies the path and filename of the code behind file  The Inherits property indicates that the code behind the page inherits the page class  This page class contains the compiled code for this page
  • 43. Compiling the Page Class  The compiled code behind the page is the class definition for the page  A class is a named logical grouping of code  The class definition contains the functions, methods, and properties that belong to that class  In Visual Studio .NET the process of compiling a class is called building  When you build the application, you compile the code into an executable file  Visual Studio .NET compiles the code behind the page into an executable file and places the file in the bin directory
  • 44. Page Class Events  The Page Class consists of a variety of methods, functions, and properties that can be accessed within the code behind the page  The first time a page is requested by a client, a series of page events occurs  The first page event is the Page_Init event which initializes the page control hierarchy  The Page_Load event loads any server controls into memory and occurs every time the page is executed
  • 45. Page class events  Page_init  Page_load  Server_Controls  Page_prerender  Page_Unload
  • 46. Web Services  Web Services also provide a means to expose .NET functionality on the web but Web Services expose functionality via XML and SOAP (cf: function calls over the web)
  • 47. Web Services  If your business partner is Course Technology and you want to query that company’s product catalog from your Web site, you could:  Post a link  Scrape a Web site (use a program to view a Web site and capture the source code)  Provide a Web Service to their catalog application  Web Services are used to create business-to- business applications  Web Services allow you to expose part or all of your programs over the Internet. The Web Service source file has the extension .asmx  A public registry known as UDDI contains registered public Web Services. Third party Web Services are available at http://www.xmethods.com
  • 48. How ASP.NET works  When .NET is installed, IIS is configured to look for files with the .aspx extension and to use the ASP.NET module (aspnet_isapi.dll) to handle them.  ASP.NET parses the .aspx file and arranges it in a predefined class definition and generates an asp.net page object.  The page object generates html that is sent back to IIS and then the browser.  NOTE: only .aspx files are parsed (if it is pure html don’t save it as an aspx file as it will slow down the server.
  • 49. ASP.NET samples  Page directives: <%@ page language = “VB” debug="true" trace="true“ %>  <script language = “VB” runat=“server”> VB.NET code declarations ……….. </script>  Message.aspx <html> <head> <title>Inserting ASP.NET code Example</title> </head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> </body> </html>  Note this has no asp code so better to use .html extension
  • 50.  Message2.aspx <script language="VB" runat="server"> Sub Page_Load() Response.Write ("First ASP.NET Line<br />") Response.Write ("Second ASP.NET Line<br />") Response.Write ("Third ASP.NET Line<br />") End Sub </script> <html> <head> <title>Inserting ASP.NET code Example</TITLE> </head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> </body> </html>
  • 51.  Message3.aspx html> <head><title>Inserting ASP.NET code Example</title></head> <body> Line1: First HTML Line<br /> Line2: Second HTML Line<br /> Line3: Third HTML Line<br /> <script language="VB" runat="server"> Sub Page_Load() Response.Write ("First ASP.NET Line<br />") Response.Write ("Second ASP.NET Line<br />") Response.Write ("Third ASP.NET Line<br />") End Sub </script> </body> </html>
  • 52. Render or inline code block – interweave1.aspx <html> <head> <title>Interweaving ASP.NET code and HTML Example</title> </head> <body> Line1: First HTML Line<br /> <% Response.Write ("First ASP.NET Line<br />") %> Line2: Second HTML Line<br /> <% Response.Write ("Second ASP.NET Line<br />") %> Line3: Third HTML Line<br /> <% Response.Write ("Third ASP.NET Line<br />") %> </body> </html> NOT RECOMMENDED.
  • 53. Interweave2.aspx A Server control script language="VB" runat="server"> Sub Page_Load() Message.Text="The ASP.NET line" End Sub </script> <html> <head> <title>Inserting ASP.NET code Example</TITLE> </head> <body> First HTML Line<br/> <asp:label id=Message runat="server"/> <br /> Second HTML Line<br/> </body>
  • 54. Web application project files AssemblyInfo.vb Info about the compiled project file stored in /bin and named project.dll Global.asax Event handler commands visible to all web forms in a project Global.asax.resx Define application resources such as text strings, images. Can change without recompiling project. Global.asax.vb Asp.net code for application events eg session.start Project.sln Stores links to all project files Project.suo VS.NET IDE configuration info for the proj. Project.vbproj Configuration and build settings for project files.
  • 55. Web application project files cont. Project.vbproj.webinfo URL to project web server Project.vsdisco Enables search for web services Styles.css Project style sheet Web.config Project and folder configuration information Webform.aspx Web form .aspx file;Html Webform.aspx.resx Resources in corresponding web form Webform.aspx.vb Code written for the form (code behind) Binproject.dll Compiled project output file (assembly) Binproject.pdb Debugging information used by developer
  • 56. Viewing the Assembly  Create a simple class, compile the class into an assembly, then view the class using the IL Disassembler  Open Notepad and type the code shown: ' hello.vb - displays hello world ' Created 06/01/2002 Imports System Public Module Hello Sub Main() Dim s1 As String = "1 - Hello World" Console.WriteLine(s1) End Sub End Module ' Run this at the command line ' vbc hello.vb
  • 57. Using the ILDASM to View the Assembly and Classes Using the ILDASM to view the assembly and classes
  • 58. Examples  quickstart – webforms  Intro4 shows VIEWSTATE  Intro6 shows a click event  Intro7 shows a usercontrol with a calander  Intro8 shows a db connection  Intro9 & 10 show asp.net templates  Intro11shows validation controls  Intro13 shows code behind pages  Server directives eg trace and debug  trace
  • 59. The lab environment.  Each machine is set up to be an IIS server – http://localhost:1900/…..  You create your web projects with Visual Studio.Net. VS.NET will create a subdirectory in c:/inetpub/wwwroot for your project. You must copy this subdirectory when moving to another machine or home.  URL  http://localhost:1900/MyfirstApp/homepage.aspx  Alternative to VS.Net is webmatrix  Some samples on another machine  http://interdev.csse.monash.edu.au/cse2030/ Interdev is not accessible outside the Monash network.
  • 60. ASP.NET Vs PHP Feature PHP ASP.NET HTML Yes Yes CSS Yes Yes ‘php Templates’ Yes UserControls ServerControls (buttons,grids etc) No Yes Javascript Yes Yes + Validation controls Database Conn Yes Yes Cookies & Sessions Yes Yes VIEWSTATE No Yes POSTBACK No Yes