SlideShare a Scribd company logo
Slide 1 of 19
Developing Web Applications Using ASP.NET
In this session, you will learn to:
Describe various event-handling techniques
Explain how to detect browser types and capabilities
Explain how to access page headers
Describe how to handle page-level errors and application-level
errors
Implement advanced techniques for handling events
Implement browser-capability detection
Implement page-header manipulation
Implement page-level and application-level error handling
Objectives
Slide 2 of 19
Developing Web Applications Using ASP.NET
ASP.NET provides you with a flexible framework that enables
you to work with event handlers in several ways.
The various approaches that can be used to work with the
event handlers include:
Using default events
Using non-default events
Using the AutoEventWireup capabilities of a Web form to
associate events and event-handling methods
Creating centralized event-handling methods to respond to
multiple events
Event Handling in Web Applications
Slide 3 of 19
Developing Web Applications Using ASP.NET
Default and Non-Default Events
ASP.NET objects usually expose an event that is designated
as the default event.
In addition to a default event, many ASP.NET objects also
expose other events, called non-default events.
Slide 4 of 19
Developing Web Applications Using ASP.NET
Non-default event handlers are used to respond to the non-
default events.
Each event has a specific signature associated with it.
Non-Default Event Handlers
Slide 5 of 19
Developing Web Applications Using ASP.NET
Event wire-ups determine the procedures that need to be
called when objects raise events.
The AutoEventWireUp property of the .aspx pages should
be set to true to indicate that procedures with well-defined
names and signatures are used as event handlers.
By default, the AutoEventWireUp property of the .aspx
pages is set to true.
<%@ Page Language=“C#” AutoEventWireup=“True”%>
Event Wire-Ups
Slide 6 of 19
Developing Web Applications Using ASP.NET
Centralized event handlers run in response to multiple events.
This helps in creating code that is easier to maintain.
Centralized Event Handlers
Slide 7 of 19
Developing Web Applications Using ASP.NET
How to Determine Which Web Server Control Raised an Event
To determine which control caused the event, you need to
perform the following steps:
In the event handler, declare a variable with a type that
matches the control that raised the event.
Assign the sender argument of the event handler to the
variable, casting it to the appropriate type.
Examine the ID property of the variable to determine which
object raised the event.
Slide 8 of 19
Developing Web Applications Using ASP.NET
When a Web browser makes a request for a Web page, it
sends information that describes the browser in the Hypertext
Transfer Protocol (HTTP) header.
You can query the information sent by the browser by using
code in the ASP.NET Web page.
Detecting the browser capability ensures that the response
the application sends to the browser is appropriate.
Much of the information sent by the Web browser is
encapsulated as properties in the Request.Browser object.
Browser Capability Detection
Slide 9 of 19
Developing Web Applications Using ASP.NET
The header section of the HTML script contains metadata for
the page such as title and styles used in the page.
The metadata is useful in search engines for categorizing the
Web pages.
The information in the page header can be used at run time
by the server-side code.
The page header information can be changed at run time.
ASP.NET exposes each Web page to your code as a
System.Web.UI.Page object.
You can use the properties of the Page.Header object,
such as the Page.Header.Title property, to query and set
its values at run time.
Page Header Retrieval
Slide 10 of 19
Developing Web Applications Using ASP.NET
How to Pass Values Between ASP.NET Web Pages
You can pass information between pages in various ways:
Use a query string that appends the information to the URL of
the target page
Expose the data as public properties on the source page
Slide 11 of 19
Developing Web Applications Using ASP.NET
The HttpServerUtility.Transfer Method
The HttpServerUtility.Transfer method performs
the following functions:
Halts the code running on the current Web page
Requests a different Web page to carry on the processing
Example:
Server.Transfer("Productdisplay.aspx?productname=
bike&color=blue");
Slide 12 of 19
Developing Web Applications Using ASP.NET
ASP.NET enables you to handle run time errors with:
Structured exception handling:
It enables you to handle exceptions in your Web applications by
using Try…Catch blocks.
Page-level error handling:
It enables you to trap all the otherwise-unhandled server-side
errors on the page.
Page_Error event of the Page object enables you to trap all the
unhandled exceptions in a page.
Application-level error handling:
It enables you to trap all the otherwise-unhandled server-side
errors in the Web application.
There are two standard approaches you can follow when
implementing an application-level error handler:
Create Application_Error event method in global.asax file
Include a <customErrors> element in the Web.config file
Page-Level and Application-Level Error Handling
Slide 13 of 19
Developing Web Applications Using ASP.NET
Handling Application-Level Errors Using <customErrors> Element
Using the <customErrors> elements requires you to
modify the web.config file of your web application.
Refer to the following code snippet:
<system.web>
<customErrors
defaultRedirect="errorhandler.aspx“ mode="On">
<error statusCode="403”
redirect=“Page1.htm"/>
<error statusCode="404”
redirect=“Page2.htm" />
</customeErrors>
</system.web>
Slide 14 of 19
Developing Web Applications Using ASP.NET
Problem Statement:
You are a developer in the Adventure Works organization, a
fictitious bicycle manufacturer. You have been asked to assist in
the development of the Business-to-Consumer (B2C) Web
application and a Business-to-Employee (B2E) extranet portal.
Decisions on the design of the application have already been
taken. You have been asked to carry out a number of specific
tasks in order to implement various elements of this design.
Demo: Programming a Web Application
Slide 15 of 19
Developing Web Applications Using ASP.NET
As part of the first phase of the B2C development, you have
been asked to complete prototypes for the following pages:
• Feedback.aspx. You will create a centralized event handler for the
Click event of two Button objects.
• Contact.aspx. You will create an event handler for the non-default
Command event of Button objects.
• Diagnostics.aspx. You will retrieve properties of the Browser object
and display them on the Web page. You will also access the
Page.Header object.
• TrailReport.aspx. You will implement a page-level error handler
that deals with all run-time errors that can occur on this Web page.
You will also modify the Web.config file to enable application-
level error handling by redirecting all otherwise-unhandled
exceptions to the customErrors.aspx page.
Demo: Programming a Web Application (Contd.)
Slide 16 of 19
Developing Web Applications Using ASP.NET
Solution:
To solve this problem, you need to perform the following tasks:
1. Implement Non-Default Event Handlers
a.Open the Adventure Works Web site.
b.Create a centralized event handler for two Button controls.
c. Specify the feedback_Click method as the Click event handler for
the feedback buttons.
d.Create an event handler for the Command event of Button controls.
e.Specify the SortGroup_Command method as the Command event
handler for the Button controls.
f. Test the Web site functionality.
Demo: Programming a Web Application (Contd.)
Slide 17 of 19
Developing Web Applications Using ASP.NET
2. Detect Browser Capabilities and Set Page Header Properties
a.Review the Diagnostics.aspx page.
b.Detect browser properties.
c. Display browser properties.
d.Modify the page title.
e.Test the Web site functionality.
3. Handle Page-Level Exceptions
a.Handle page-level exceptions.
b.Handle exceptions at the application level.
c. Test exception handling.
Demo: Programming a Web Application (Contd.)
Slide 18 of 19
Developing Web Applications Using ASP.NET
In this session, you learned that:
ASP.NET objects usually expose an event that is designated
as the default event.
In addition to the default event, ASP.NET objects expose other
additional events known as non-default events.
When you want to write code that responds to a non-default
event, you need to define an event handler for it.
Event wire-ups are the mechanism that ASP.NET uses to
determine which procedures to call when objects raise events.
By default, the AutoEventWireUp attribute for .aspx pages is
set to true.
When a Web browser makes a request for a Web page, it
sends information that describes the browser in the Hypertext
Transfer Protocol (HTTP) header.
Summary
Slide 19 of 19
Developing Web Applications Using ASP.NET
Centralized event handlers run in response to multiple events.
ASP.NET provides a robust and flexible error-handling
framework. It enables you to handle run-time errors with:
Structured exception handling
Page-level error handlers
Application-level error handlers
Summary (Contd.)

More Related Content

What's hot

Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extension
Rebecca Peltz
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
Atlassian
 
Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9
Abram John Limpin
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
Raveendra R
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
Vivek chan
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
Raveendra R
 
IE9 for developers
IE9 for developersIE9 for developers
IE9 for developers
Shaymaa
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
OS-Cubed, Inc.
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
Bhushan Mulmule
 
Lightning Components Workshop v2
Lightning Components Workshop v2Lightning Components Workshop v2
Lightning Components Workshop v2
Christophe Coenraets
 
Offline Storage
Offline StorageOffline Storage
Offline Storage
SP Balamurugan
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011
Iskandar Najmuddin
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
Randy Connolly
 
Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
Mohd Manzoor Ahmed
 
10 practices that every developer needs to start right now
10 practices that every developer needs to start right now10 practices that every developer needs to start right now
10 practices that every developer needs to start right now
Caleb Jenkins
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
Christophe Coenraets
 
Building i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadinBuilding i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadin
Joonas Lehtinen
 
IBM cognos work space configuration.pptx
IBM cognos work space configuration.pptxIBM cognos work space configuration.pptx
IBM cognos work space configuration.pptx
vishal choudhary
 
Building mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKitBuilding mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKit
Sami Ekblad
 

What's hot (20)

Make an html validator extension
Make an html validator extensionMake an html validator extension
Make an html validator extension
 
Intro Open Social and Dashboards
Intro Open Social and DashboardsIntro Open Social and Dashboards
Intro Open Social and Dashboards
 
Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9Pinned Sites in Internet Explorer 9
Pinned Sites in Internet Explorer 9
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
 
Introduction to AngularJS Framework
Introduction to AngularJS FrameworkIntroduction to AngularJS Framework
Introduction to AngularJS Framework
 
IE9 for developers
IE9 for developersIE9 for developers
IE9 for developers
 
Creating a content managed facebook app
Creating a content managed facebook appCreating a content managed facebook app
Creating a content managed facebook app
 
Implementing auto complete using JQuery
Implementing auto complete using JQueryImplementing auto complete using JQuery
Implementing auto complete using JQuery
 
Lightning Components Workshop v2
Lightning Components Workshop v2Lightning Components Workshop v2
Lightning Components Workshop v2
 
Offline Storage
Offline StorageOffline Storage
Offline Storage
 
What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011What's New on the Facebook Platform, July 2011
What's New on the Facebook Platform, July 2011
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
 
Angularjs Live Project
Angularjs Live ProjectAngularjs Live Project
Angularjs Live Project
 
10 practices that every developer needs to start right now
10 practices that every developer needs to start right now10 practices that every developer needs to start right now
10 practices that every developer needs to start right now
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
 
Building i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadinBuilding i pad apps in pure java with vaadin
Building i pad apps in pure java with vaadin
 
Training On Angular Js
Training On Angular JsTraining On Angular Js
Training On Angular Js
 
IBM cognos work space configuration.pptx
IBM cognos work space configuration.pptxIBM cognos work space configuration.pptx
IBM cognos work space configuration.pptx
 
Building mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKitBuilding mobile applications with Vaadin TouchKit
Building mobile applications with Vaadin TouchKit
 

Viewers also liked

CyberLab Training Division
CyberLab Training DivisionCyberLab Training Division
CyberLab Training Division
Vivek chan
 
CyberLab Development Division
CyberLab Development Division CyberLab Development Division
CyberLab Development Division
Vivek chan
 
09 asp.net session13
09 asp.net session1309 asp.net session13
09 asp.net session13
Vivek chan
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
Vivek chan
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10
Vivek chan
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
Vivek chan
 
04 intel v_tune_session_05
04 intel v_tune_session_0504 intel v_tune_session_05
04 intel v_tune_session_05
Vivek chan
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Vivek chan
 
Net framework session03
Net framework session03Net framework session03
Net framework session03
Vivek chan
 
01 intel v_tune_session_01
01 intel v_tune_session_0101 intel v_tune_session_01
01 intel v_tune_session_01
Vivek chan
 
CyberLab Work-EX Program
CyberLab Work-EX ProgramCyberLab Work-EX Program
CyberLab Work-EX Program
Vivek chan
 
CyberLab Vehicle Tracking System
CyberLab Vehicle Tracking SystemCyberLab Vehicle Tracking System
CyberLab Vehicle Tracking System
Vivek chan
 
03 intel v_tune_session_04
03 intel v_tune_session_0403 intel v_tune_session_04
03 intel v_tune_session_04
Vivek chan
 
What is Robotics - Robotics Concept Explained for Kids
What is Robotics - Robotics Concept Explained for KidsWhat is Robotics - Robotics Concept Explained for Kids
What is Robotics - Robotics Concept Explained for Kids
Vivek chan
 
Self driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking driversSelf driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking drivers
Vivek chan
 
Complete Osi Model Explained
Complete Osi Model ExplainedComplete Osi Model Explained
Complete Osi Model Explained
Vivek chan
 

Viewers also liked (16)

CyberLab Training Division
CyberLab Training DivisionCyberLab Training Division
CyberLab Training Division
 
CyberLab Development Division
CyberLab Development Division CyberLab Development Division
CyberLab Development Division
 
09 asp.net session13
09 asp.net session1309 asp.net session13
09 asp.net session13
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
04 intel v_tune_session_05
04 intel v_tune_session_0504 intel v_tune_session_05
04 intel v_tune_session_05
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
Net framework session03
Net framework session03Net framework session03
Net framework session03
 
01 intel v_tune_session_01
01 intel v_tune_session_0101 intel v_tune_session_01
01 intel v_tune_session_01
 
CyberLab Work-EX Program
CyberLab Work-EX ProgramCyberLab Work-EX Program
CyberLab Work-EX Program
 
CyberLab Vehicle Tracking System
CyberLab Vehicle Tracking SystemCyberLab Vehicle Tracking System
CyberLab Vehicle Tracking System
 
03 intel v_tune_session_04
03 intel v_tune_session_0403 intel v_tune_session_04
03 intel v_tune_session_04
 
What is Robotics - Robotics Concept Explained for Kids
What is Robotics - Robotics Concept Explained for KidsWhat is Robotics - Robotics Concept Explained for Kids
What is Robotics - Robotics Concept Explained for Kids
 
Self driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking driversSelf driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking drivers
 
Complete Osi Model Explained
Complete Osi Model ExplainedComplete Osi Model Explained
Complete Osi Model Explained
 

Similar to 02 asp.net session02

02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Niit Care
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
Vivek chan
 
Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Michael Dobe, Ph.D.
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
Rasan Samarasinghe
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Vivek chan
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Niit Care
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Mani Chaubey
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
ssuserc28c7c1
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Niit Care
 
Asp
AspAsp
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10Niit Care
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer home
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1Neeraj Mathur
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
Paneliya Prince
 
Windows8 metro presentationupdated
Windows8 metro presentationupdatedWindows8 metro presentationupdated
Windows8 metro presentationupdated
Dhananjay Kumar
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01Mani Chaubey
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Vivek chan
 
Programming web application
Programming web applicationProgramming web application
Programming web applicationaspnet123
 

Similar to 02 asp.net session02 (20)

02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)
 
DITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NETDITEC - E-Commerce & ASP.NET
DITEC - E-Commerce & ASP.NET
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
Beyond The MVC
Beyond The MVCBeyond The MVC
Beyond The MVC
 
Asp
AspAsp
Asp
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Asp interview Question and Answer
Asp interview Question and Answer Asp interview Question and Answer
Asp interview Question and Answer
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Windows8 metro presentationupdated
Windows8 metro presentationupdatedWindows8 metro presentationupdated
Windows8 metro presentationupdated
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 

More from Vivek chan

Deceptive Marketing.pdf
Deceptive Marketing.pdfDeceptive Marketing.pdf
Deceptive Marketing.pdf
Vivek chan
 
brain controled wheel chair.pdf
brain controled wheel chair.pdfbrain controled wheel chair.pdf
brain controled wheel chair.pdf
Vivek chan
 
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Vivek chan
 
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Manav dharma shashtra tatha shashan paddati   munshiram jigyasuManav dharma shashtra tatha shashan paddati   munshiram jigyasu
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Vivek chan
 
EEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using ThoughtsEEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using Thoughts
Vivek chan
 
Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant
Vivek chan
 
Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant
Vivek chan
 
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Vivek chan
 
Net framework session01
Net framework session01Net framework session01
Net framework session01
Vivek chan
 
Net framework session02
Net framework session02Net framework session02
Net framework session02
Vivek chan
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
Vivek chan
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
Vivek chan
 
07 intel v_tune_session_10
07 intel v_tune_session_1007 intel v_tune_session_10
07 intel v_tune_session_10
Vivek chan
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22
Vivek chan
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
Vivek chan
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
Vivek chan
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Vivek chan
 

More from Vivek chan (17)

Deceptive Marketing.pdf
Deceptive Marketing.pdfDeceptive Marketing.pdf
Deceptive Marketing.pdf
 
brain controled wheel chair.pdf
brain controled wheel chair.pdfbrain controled wheel chair.pdf
brain controled wheel chair.pdf
 
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
 
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Manav dharma shashtra tatha shashan paddati   munshiram jigyasuManav dharma shashtra tatha shashan paddati   munshiram jigyasu
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
 
EEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using ThoughtsEEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using Thoughts
 
Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant
 
Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant Vivek Chan | Technology Consultant
Vivek Chan | Technology Consultant
 
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
 
Net framework session01
Net framework session01Net framework session01
Net framework session01
 
Net framework session02
Net framework session02Net framework session02
Net framework session02
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
 
07 intel v_tune_session_10
07 intel v_tune_session_1007 intel v_tune_session_10
07 intel v_tune_session_10
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 

Recently uploaded

How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 

Recently uploaded (20)

How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 

02 asp.net session02

  • 1. Slide 1 of 19 Developing Web Applications Using ASP.NET In this session, you will learn to: Describe various event-handling techniques Explain how to detect browser types and capabilities Explain how to access page headers Describe how to handle page-level errors and application-level errors Implement advanced techniques for handling events Implement browser-capability detection Implement page-header manipulation Implement page-level and application-level error handling Objectives
  • 2. Slide 2 of 19 Developing Web Applications Using ASP.NET ASP.NET provides you with a flexible framework that enables you to work with event handlers in several ways. The various approaches that can be used to work with the event handlers include: Using default events Using non-default events Using the AutoEventWireup capabilities of a Web form to associate events and event-handling methods Creating centralized event-handling methods to respond to multiple events Event Handling in Web Applications
  • 3. Slide 3 of 19 Developing Web Applications Using ASP.NET Default and Non-Default Events ASP.NET objects usually expose an event that is designated as the default event. In addition to a default event, many ASP.NET objects also expose other events, called non-default events.
  • 4. Slide 4 of 19 Developing Web Applications Using ASP.NET Non-default event handlers are used to respond to the non- default events. Each event has a specific signature associated with it. Non-Default Event Handlers
  • 5. Slide 5 of 19 Developing Web Applications Using ASP.NET Event wire-ups determine the procedures that need to be called when objects raise events. The AutoEventWireUp property of the .aspx pages should be set to true to indicate that procedures with well-defined names and signatures are used as event handlers. By default, the AutoEventWireUp property of the .aspx pages is set to true. <%@ Page Language=“C#” AutoEventWireup=“True”%> Event Wire-Ups
  • 6. Slide 6 of 19 Developing Web Applications Using ASP.NET Centralized event handlers run in response to multiple events. This helps in creating code that is easier to maintain. Centralized Event Handlers
  • 7. Slide 7 of 19 Developing Web Applications Using ASP.NET How to Determine Which Web Server Control Raised an Event To determine which control caused the event, you need to perform the following steps: In the event handler, declare a variable with a type that matches the control that raised the event. Assign the sender argument of the event handler to the variable, casting it to the appropriate type. Examine the ID property of the variable to determine which object raised the event.
  • 8. Slide 8 of 19 Developing Web Applications Using ASP.NET When a Web browser makes a request for a Web page, it sends information that describes the browser in the Hypertext Transfer Protocol (HTTP) header. You can query the information sent by the browser by using code in the ASP.NET Web page. Detecting the browser capability ensures that the response the application sends to the browser is appropriate. Much of the information sent by the Web browser is encapsulated as properties in the Request.Browser object. Browser Capability Detection
  • 9. Slide 9 of 19 Developing Web Applications Using ASP.NET The header section of the HTML script contains metadata for the page such as title and styles used in the page. The metadata is useful in search engines for categorizing the Web pages. The information in the page header can be used at run time by the server-side code. The page header information can be changed at run time. ASP.NET exposes each Web page to your code as a System.Web.UI.Page object. You can use the properties of the Page.Header object, such as the Page.Header.Title property, to query and set its values at run time. Page Header Retrieval
  • 10. Slide 10 of 19 Developing Web Applications Using ASP.NET How to Pass Values Between ASP.NET Web Pages You can pass information between pages in various ways: Use a query string that appends the information to the URL of the target page Expose the data as public properties on the source page
  • 11. Slide 11 of 19 Developing Web Applications Using ASP.NET The HttpServerUtility.Transfer Method The HttpServerUtility.Transfer method performs the following functions: Halts the code running on the current Web page Requests a different Web page to carry on the processing Example: Server.Transfer("Productdisplay.aspx?productname= bike&color=blue");
  • 12. Slide 12 of 19 Developing Web Applications Using ASP.NET ASP.NET enables you to handle run time errors with: Structured exception handling: It enables you to handle exceptions in your Web applications by using Try…Catch blocks. Page-level error handling: It enables you to trap all the otherwise-unhandled server-side errors on the page. Page_Error event of the Page object enables you to trap all the unhandled exceptions in a page. Application-level error handling: It enables you to trap all the otherwise-unhandled server-side errors in the Web application. There are two standard approaches you can follow when implementing an application-level error handler: Create Application_Error event method in global.asax file Include a <customErrors> element in the Web.config file Page-Level and Application-Level Error Handling
  • 13. Slide 13 of 19 Developing Web Applications Using ASP.NET Handling Application-Level Errors Using <customErrors> Element Using the <customErrors> elements requires you to modify the web.config file of your web application. Refer to the following code snippet: <system.web> <customErrors defaultRedirect="errorhandler.aspx“ mode="On"> <error statusCode="403” redirect=“Page1.htm"/> <error statusCode="404” redirect=“Page2.htm" /> </customeErrors> </system.web>
  • 14. Slide 14 of 19 Developing Web Applications Using ASP.NET Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in the development of the Business-to-Consumer (B2C) Web application and a Business-to-Employee (B2E) extranet portal. Decisions on the design of the application have already been taken. You have been asked to carry out a number of specific tasks in order to implement various elements of this design. Demo: Programming a Web Application
  • 15. Slide 15 of 19 Developing Web Applications Using ASP.NET As part of the first phase of the B2C development, you have been asked to complete prototypes for the following pages: • Feedback.aspx. You will create a centralized event handler for the Click event of two Button objects. • Contact.aspx. You will create an event handler for the non-default Command event of Button objects. • Diagnostics.aspx. You will retrieve properties of the Browser object and display them on the Web page. You will also access the Page.Header object. • TrailReport.aspx. You will implement a page-level error handler that deals with all run-time errors that can occur on this Web page. You will also modify the Web.config file to enable application- level error handling by redirecting all otherwise-unhandled exceptions to the customErrors.aspx page. Demo: Programming a Web Application (Contd.)
  • 16. Slide 16 of 19 Developing Web Applications Using ASP.NET Solution: To solve this problem, you need to perform the following tasks: 1. Implement Non-Default Event Handlers a.Open the Adventure Works Web site. b.Create a centralized event handler for two Button controls. c. Specify the feedback_Click method as the Click event handler for the feedback buttons. d.Create an event handler for the Command event of Button controls. e.Specify the SortGroup_Command method as the Command event handler for the Button controls. f. Test the Web site functionality. Demo: Programming a Web Application (Contd.)
  • 17. Slide 17 of 19 Developing Web Applications Using ASP.NET 2. Detect Browser Capabilities and Set Page Header Properties a.Review the Diagnostics.aspx page. b.Detect browser properties. c. Display browser properties. d.Modify the page title. e.Test the Web site functionality. 3. Handle Page-Level Exceptions a.Handle page-level exceptions. b.Handle exceptions at the application level. c. Test exception handling. Demo: Programming a Web Application (Contd.)
  • 18. Slide 18 of 19 Developing Web Applications Using ASP.NET In this session, you learned that: ASP.NET objects usually expose an event that is designated as the default event. In addition to the default event, ASP.NET objects expose other additional events known as non-default events. When you want to write code that responds to a non-default event, you need to define an event handler for it. Event wire-ups are the mechanism that ASP.NET uses to determine which procedures to call when objects raise events. By default, the AutoEventWireUp attribute for .aspx pages is set to true. When a Web browser makes a request for a Web page, it sends information that describes the browser in the Hypertext Transfer Protocol (HTTP) header. Summary
  • 19. Slide 19 of 19 Developing Web Applications Using ASP.NET Centralized event handlers run in response to multiple events. ASP.NET provides a robust and flexible error-handling framework. It enables you to handle run-time errors with: Structured exception handling Page-level error handlers Application-level error handlers Summary (Contd.)