SlideShare a Scribd company logo
1 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Objectives


                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




     Ver. 1.0                                                            Slide 1 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Event Handling in Web Applications


                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




     Ver. 1.0                                                           Slide 2 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
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.




     Ver. 1.0                                                       Slide 3 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Non-Default Event Handlers


                Non-default event handlers are used to respond to the
                non-default events.
                Each event has a specific signature associated with it.




     Ver. 1.0                                                        Slide 4 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Event Wire-Ups


                •   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”%>




     Ver. 1.0                                                           Slide 5 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Centralized Event Handlers


                Centralized event handlers run in response to multiple
                events.
                This helps in creating code that is easier to maintain.




     Ver. 1.0                                                         Slide 6 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
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.




     Ver. 1.0                                                           Slide 7 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Browser Capability Detection


                •   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.




     Ver. 1.0                                                          Slide 8 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Page Header Retrieval


                •   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.



     Ver. 1.0                                                          Slide 9 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
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




     Ver. 1.0                                                            Slide 10 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
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");




     Ver. 1.0                                                              Slide 11 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Page-Level and Application-Level Error Handling


                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


     Ver. 1.0                                                                   Slide 12 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
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>




     Ver. 1.0                                                        Slide 13 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Demo: Programming a Web Application


                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.




     Ver. 1.0                                                            Slide 14 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Demo: Programming a Web Application (Contd.)


                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.




     Ver. 1.0                                                                Slide 15 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Demo: Programming a Web Application (Contd.)


                Solution:
                   To solve this problem, you need to perform the following tasks:
                    1. Implement Non-Default Event Handlers
                        – Open the Adventure Works Web site.
                        – Create a centralized event handler for two Button controls.
                        – Specify the feedback_Click method as the Click event handler for
                          the feedback buttons.
                        – Create an event handler for the Command event of Button controls.
                        – Specify the SortGroup_Command method as the Command event
                          handler for the Button controls.
                        – Test the Web site functionality.




     Ver. 1.0                                                                      Slide 16 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Demo: Programming a Web Application (Contd.)


                1. 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.
                2. Handle Page-Level Exceptions
                    a. Handle page-level exceptions.
                    b. Handle exceptions at the application level.
                    c. Test exception handling.




     Ver. 1.0                                                            Slide 17 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Summary


                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.



     Ver. 1.0                                                            Slide 18 of 19
Installing Windows XPApplications Using ASP.NET
Developing Web Professional Using Attended Installation
Summary (Contd.)


                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




     Ver. 1.0                                                         Slide 19 of 19

More Related Content

What's hot

Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web applicationRahul Bansal
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Niit Care
 
Chapter6 web apps-tomcat
Chapter6 web apps-tomcatChapter6 web apps-tomcat
Chapter6 web apps-tomcatVenkat Gowda
 
Joe Staner Zend Con 2008
Joe Staner Zend Con 2008Joe Staner Zend Con 2008
Joe Staner Zend Con 2008ZendCon
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Niit Care
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...Mark Leusink
 
AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )senthil0809
 
1 app 2 developers 3 servers
1 app 2 developers 3 servers1 app 2 developers 3 servers
1 app 2 developers 3 serversMark Myers
 
PHP konferencija - Microsoft
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoftnusmas
 
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformWordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformGeorge Kanellopoulos
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.netSHADAB ALI
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebGeorge Kanellopoulos
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web ApplicationRishi Kothari
 
SPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add insSPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add insNCCOMMS
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformAlfresco Software
 
Php apache vs iis By Hafedh Yahmadi
Php apache vs iis  By Hafedh YahmadiPhp apache vs iis  By Hafedh Yahmadi
Php apache vs iis By Hafedh YahmadiTechdaysTunisia
 

What's hot (20)

Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Chapter6 web apps-tomcat
Chapter6 web apps-tomcatChapter6 web apps-tomcat
Chapter6 web apps-tomcat
 
Joe Staner Zend Con 2008
Joe Staner Zend Con 2008Joe Staner Zend Con 2008
Joe Staner Zend Con 2008
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
The future of web development write once, run everywhere with angular js an...
The future of web development   write once, run everywhere with angular js an...The future of web development   write once, run everywhere with angular js an...
The future of web development write once, run everywhere with angular js an...
 
Asp net
Asp netAsp net
Asp net
 
AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )
 
1 app 2 developers 3 servers
1 app 2 developers 3 servers1 app 2 developers 3 servers
1 app 2 developers 3 servers
 
PHP konferencija - Microsoft
PHP konferencija - MicrosoftPHP konferencija - Microsoft
PHP konferencija - Microsoft
 
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web PlatformWordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
Wordcamp Thessaloniki 2011 Wordpress and Microsoft Web Platform
 
Asp.net
Asp.netAsp.net
Asp.net
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Wordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The NextwebWordcamp Thessaloniki 2011 The Nextweb
Wordcamp Thessaloniki 2011 The Nextweb
 
WSS And Share Point For Developers
WSS And Share Point For DevelopersWSS And Share Point For Developers
WSS And Share Point For Developers
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
SPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add insSPUnite17 Become a Developer Hero by Building Office Add ins
SPUnite17 Become a Developer Hero by Building Office Add ins
 
Introduction to Alfresco Surf Platform
Introduction to Alfresco Surf PlatformIntroduction to Alfresco Surf Platform
Introduction to Alfresco Surf Platform
 
Php apache vs iis By Hafedh Yahmadi
Php apache vs iis  By Hafedh YahmadiPhp apache vs iis  By Hafedh Yahmadi
Php apache vs iis By Hafedh Yahmadi
 
Tutorial 1
Tutorial 1Tutorial 1
Tutorial 1
 

Viewers also liked

simple present tense
simple present tensesimple present tense
simple present tensekarwinda
 
Mantenimiento de computo
Mantenimiento de computoMantenimiento de computo
Mantenimiento de computosebassevitas
 
Otsuma(2010727)
Otsuma(2010727)Otsuma(2010727)
Otsuma(2010727)真 岡本
 
CacharreAndo
CacharreAndoCacharreAndo
CacharreAndoYcRF
 
159267237 extractos-alquimicos
159267237 extractos-alquimicos159267237 extractos-alquimicos
159267237 extractos-alquimicosgeogomes the best
 
Presentación1
Presentación1Presentación1
Presentación1pipe-alejo
 
Idocaedro aplicacion
Idocaedro aplicacionIdocaedro aplicacion
Idocaedro aplicacionAnni Lovee
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10Niit Care
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08Niit Care
 
Presentación del sistema genesis y portal institucional j a
Presentación del sistema genesis y portal institucional j aPresentación del sistema genesis y portal institucional j a
Presentación del sistema genesis y portal institucional j afelipegomezg
 
Shizuoka pref public_library(20101020)
Shizuoka pref public_library(20101020)Shizuoka pref public_library(20101020)
Shizuoka pref public_library(20101020)真 岡本
 
Jadwal kegiatan ujian smk muhammadiyah 1
Jadwal kegiatan ujian smk muhammadiyah 1Jadwal kegiatan ujian smk muhammadiyah 1
Jadwal kegiatan ujian smk muhammadiyah 1heri baskoro
 
FEA Final Report - Jawanza Bassue
FEA Final Report - Jawanza BassueFEA Final Report - Jawanza Bassue
FEA Final Report - Jawanza BassueJawanza Bassue
 
High Altitude Research Plane_Jawanza Bassue
High Altitude Research Plane_Jawanza BassueHigh Altitude Research Plane_Jawanza Bassue
High Altitude Research Plane_Jawanza BassueJawanza Bassue
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06Niit Care
 
Ki kd tkj kelas x xi dan xii
Ki kd tkj kelas x xi dan xiiKi kd tkj kelas x xi dan xii
Ki kd tkj kelas x xi dan xiiheri baskoro
 
Kisi kisi-ujian-nasional-2016-smk 2
Kisi kisi-ujian-nasional-2016-smk 2Kisi kisi-ujian-nasional-2016-smk 2
Kisi kisi-ujian-nasional-2016-smk 2heri baskoro
 

Viewers also liked (20)

Mi materia preferida
Mi materia preferidaMi materia preferida
Mi materia preferida
 
simple present tense
simple present tensesimple present tense
simple present tense
 
Mantenimiento de computo
Mantenimiento de computoMantenimiento de computo
Mantenimiento de computo
 
Otsuma(2010727)
Otsuma(2010727)Otsuma(2010727)
Otsuma(2010727)
 
CacharreAndo
CacharreAndoCacharreAndo
CacharreAndo
 
159267237 extractos-alquimicos
159267237 extractos-alquimicos159267237 extractos-alquimicos
159267237 extractos-alquimicos
 
Presentación1
Presentación1Presentación1
Presentación1
 
Presentación junio
Presentación junioPresentación junio
Presentación junio
 
Idocaedro aplicacion
Idocaedro aplicacionIdocaedro aplicacion
Idocaedro aplicacion
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 
Presentación del sistema genesis y portal institucional j a
Presentación del sistema genesis y portal institucional j aPresentación del sistema genesis y portal institucional j a
Presentación del sistema genesis y portal institucional j a
 
Shizuoka pref public_library(20101020)
Shizuoka pref public_library(20101020)Shizuoka pref public_library(20101020)
Shizuoka pref public_library(20101020)
 
Jadwal kegiatan ujian smk muhammadiyah 1
Jadwal kegiatan ujian smk muhammadiyah 1Jadwal kegiatan ujian smk muhammadiyah 1
Jadwal kegiatan ujian smk muhammadiyah 1
 
FEA Final Report - Jawanza Bassue
FEA Final Report - Jawanza BassueFEA Final Report - Jawanza Bassue
FEA Final Report - Jawanza Bassue
 
High Altitude Research Plane_Jawanza Bassue
High Altitude Research Plane_Jawanza BassueHigh Altitude Research Plane_Jawanza Bassue
High Altitude Research Plane_Jawanza Bassue
 
Aae oop xp_06
Aae oop xp_06Aae oop xp_06
Aae oop xp_06
 
02 penyusunan rpp
02 penyusunan rpp02 penyusunan rpp
02 penyusunan rpp
 
Ki kd tkj kelas x xi dan xii
Ki kd tkj kelas x xi dan xiiKi kd tkj kelas x xi dan xii
Ki kd tkj kelas x xi dan xii
 
Kisi kisi-ujian-nasional-2016-smk 2
Kisi kisi-ujian-nasional-2016-smk 2Kisi kisi-ujian-nasional-2016-smk 2
Kisi kisi-ujian-nasional-2016-smk 2
 

Similar to 02 asp.net session02

Similar to 02 asp.net session02 (20)

02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
 
Web development using asp.net
Web development using asp.netWeb development using asp.net
Web development using asp.net
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
Web techh
Web techhWeb techh
Web techh
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
 
09 asp.net session13
09 asp.net session1309 asp.net session13
09 asp.net session13
 
Walther Ajax4
Walther Ajax4Walther Ajax4
Walther Ajax4
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
Asp.net Web Development.pdf
Asp.net Web Development.pdfAsp.net Web Development.pdf
Asp.net Web Development.pdf
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
 
Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)Rutgers - FrontPage 98 (Advanced)
Rutgers - FrontPage 98 (Advanced)
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Recently uploaded

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Recently uploaded (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

02 asp.net session02

  • 1. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Objectives 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 Ver. 1.0 Slide 1 of 19
  • 2. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Event Handling in Web Applications 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 Ver. 1.0 Slide 2 of 19
  • 3. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation 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. Ver. 1.0 Slide 3 of 19
  • 4. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Non-Default Event Handlers Non-default event handlers are used to respond to the non-default events. Each event has a specific signature associated with it. Ver. 1.0 Slide 4 of 19
  • 5. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Event Wire-Ups • 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”%> Ver. 1.0 Slide 5 of 19
  • 6. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Centralized Event Handlers Centralized event handlers run in response to multiple events. This helps in creating code that is easier to maintain. Ver. 1.0 Slide 6 of 19
  • 7. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation 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. Ver. 1.0 Slide 7 of 19
  • 8. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Browser Capability Detection • 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. Ver. 1.0 Slide 8 of 19
  • 9. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Page Header Retrieval • 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. Ver. 1.0 Slide 9 of 19
  • 10. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation 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 Ver. 1.0 Slide 10 of 19
  • 11. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation 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"); Ver. 1.0 Slide 11 of 19
  • 12. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Page-Level and Application-Level Error Handling 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 Ver. 1.0 Slide 12 of 19
  • 13. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation 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> Ver. 1.0 Slide 13 of 19
  • 14. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Demo: Programming a Web Application 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. Ver. 1.0 Slide 14 of 19
  • 15. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Demo: Programming a Web Application (Contd.) 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. Ver. 1.0 Slide 15 of 19
  • 16. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Demo: Programming a Web Application (Contd.) Solution: To solve this problem, you need to perform the following tasks: 1. Implement Non-Default Event Handlers – Open the Adventure Works Web site. – Create a centralized event handler for two Button controls. – Specify the feedback_Click method as the Click event handler for the feedback buttons. – Create an event handler for the Command event of Button controls. – Specify the SortGroup_Command method as the Command event handler for the Button controls. – Test the Web site functionality. Ver. 1.0 Slide 16 of 19
  • 17. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Demo: Programming a Web Application (Contd.) 1. 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. 2. Handle Page-Level Exceptions a. Handle page-level exceptions. b. Handle exceptions at the application level. c. Test exception handling. Ver. 1.0 Slide 17 of 19
  • 18. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Summary 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. Ver. 1.0 Slide 18 of 19
  • 19. Installing Windows XPApplications Using ASP.NET Developing Web Professional Using Attended Installation Summary (Contd.) 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 Ver. 1.0 Slide 19 of 19

Editor's Notes

  1. Begin the session by sharing the objectives with the students. Tell the students that at the end of this session, they will be able to use the event handling capabilities of ASP.NET 2.0. Tell the students that at the end of the session, they will be able to create a common event handler for various controls of the same type, which would help them in making their code simpler. Further, they will be able to detect the capability of various browsers. Next, they would be able to handle run time errors by using various error handling techniques.
  2. In this section, initiate a discussion on the default events. A default event is the event, which is most commonly associated with that control. Tell the students that when they click a Button control on the .aspx page, the code for the event handler of the Click event is displayed in the code window. This is because the Click event is the default event of the Button control.
  3. In this section, explain that apart from the default event, ASP.NET objects also have various non-default events. For example, Command event is the non-default event of a button control. To create an event handler for a non-default event of a control, you can perform the following steps: 1. Select the control from the Design view and press F4 to display the Properties window. 2. In the Properties window, click the Events button. This displays a list of events for the control. 3. Locate the event for which you want to create the handler. 4. In the event name box, type the name of an event handler or d ouble-click the event name box to create a handler. This creates a new event handler with the name you typed or with the generated name.
  4. In this section, explain the event wire-up mechanism in ASP.NET. Explain that if the handlers for the events are created explicitly, then the automatic binding of the page events is controlled by the page property, AutoEventWireup.Tell the students that if they want to include explicit binding for page events, then the AutoEventWireup property should be set to false. This would ensure that the method is not inadvertently called twice. Explain that AutoEventWireup property can be set to false by adding the attribute AutoEventWireup=false in the @ Page directive.
  5. In this section, initiate a discussion on centralized event handlers. Tell the students that centralized event handlers eliminates the need for declaring separate event handlers for different ASP.NET objects. You can create one centralized event handler that can perform appropriate redirection during runtime. You can explain the same with the help of an example given in the Student Guide.
  6. In this section, explain the steps for determining the which control caused the event. Explain the same with the help of example given in the resource toolkit.
  7. In this section, discuss the various information held by the HTTP header of the browser. Next, discuss the advantage of detecting the browser capabilities. Explain the same with the help of the examples given in the Student Guide. Next, discuss about the Request.Browser object. Tell the students that the Request.Browser object enables you to retrieve various information about the browser such as browser type and version. Explain the same with the help of the code snippet given in the resource toolkit.
  8. In this section, discuss how the page header information can be used and manipulated during run time. Discuss how to alter the page title with the help of the code snippet given in the resource toolkit.
  9. In this section, explain how the information can be passed between the ASP.NET web pages by discussing the points given in the slide. Refer to the toolkit for the same. Tell the students that if the target page is an ASP.NET web page, then the value of the query string can be read by using the QueryString property of the HttpRequest object. In addition to the points discussed in the slide, you can also pass information between the pages with the help of the session state. In this case, session state is used to store information, which is then accessible to all the ASP.NET pages of the current web application. However, the disadvantage associated with this approach is that the information is stored until the session expires and take s the server memory. This leads to an additional overhead.
  10. In this section, initiate a discussion on the HttpServerUtility.Transfer method by referring to the Resource Toolkit. While displaying a different web page, ASP.NET does not verify whether the current user is authorized to view the web page delivered by the HttpServerUtility.Transfer method or not. This problem can be solved by using the HttpResponse.Redirect method. Unlike the HttpServerUtility.Transfer method, the HttpResponse.Redirect method forces reauthorization and checks whether the user is authorized to view that web page or not. Next, discuss about the Server.Transfer method. Explain that the Server.Transfer method enables you to pass values between ASP.NET Web pages. For more details, you can refer to the Resource Toolkit.
  11. In this section, discuss about various error handling mechanisms provided by ASP.NET. Reiterate the concept of a Try…Catch block. Next, tell the students that ASP.NET automatically binds application events to event-handler methods in the Global.asax file. The naming convention used for the handler is Application _event . There can be various application-level event handlers in the Global.asax file such as Application_BeginRequest and Application_Error . Explain that to create application-level event handler, you need to perform the following steps: Create a Global.asax file in the root of the site, if your Web site does not already have one. Create an event-handler method whose name follows the pattern Application_event. For example, to handle an application Error event, create a handler named Application_Error that takes an Object parameter and an EventArgs parameter. Refer to the following code snippet: void Application_Error(Object sender, EventArgs e) {}
  12. In this section, explain the process of handling application level errors by using the &lt;customErrors&gt; element. Explain the same with the help of the code snippet given in the slide. Explain the students that the mode can be set to On, Off or RemoteOnly. Next, explain that when an error occurs, you can redirect to a different web page depending upon the type of the error. To determine which type of error has occurred, you can use the statusCode property of the error element. If an error of that particular statuCode occurs, the web application is redirected to a different web page. Refer to code snippet given in the slide. If an error of statusCode 403 occurs, the web application is redirected to NoAccess.htm page. Similarly, if an error of the status code 404 occurs, then the web application is redirected to FileNotFound.htm page. In this case, it is not possible to trap all the types of errors that may occur in a web application. In such a case, you can redirect the application to a default page by assigning its URL to the defaultRedirect property.
  13. In this slide and the next slide, discuss the problem statement with the students.
  14. Explain to the students how to determine the Web server control that raised an event. Explain the same with the help of the code given in the Resource Toolkit. Next, explain to the students that they can also bind an event to a handler by editing the HTML source code for the ASP.NET page. Explain the same with the help of the code snippet given in the Resource Toolkit. Next, explain the students that they can determine which button was clicked at run time with the help of the Button.Command event. Explain the same in detail by referring to the Resource Toolkit. Explain to the students that they can create a common event handler for the Click event or Command event of a Button control. Both of these approaches can be used to accomplish the same task. The difference between these two approaches lies in the syntax being used. When you declare an event handler for the Click event of a Button control, then this requires you to declare a protected method with two arguments, one of Object type and another of EventArgs type. However, when you declare an event handler for the Command event, the second argument is of CommandEventArgs type. The data type of the first argument is same as that of the event handler of the Click event.
  15. Tell the students that they can change the Page.Header.Title property. Explain the same with the help of the code snippet given in the Resource Toolkit. Next, tell the students that Page_Error is the event handler for the Page.Error event. Next, initiate a discussion on the application-level error handling strategies. Explain how Web.config file for the application can be modified to configure application-level error handling by referring to the Resource Toolkit. Tell the students that they can use the Application_Error event handler in the global.asax file of the Web application. Tell the students that if the Web.config file has customErrors set to Off, then the Application_Error event handler in Global.asax will process all unhandled errors.
  16. Summarize the session.
  17. Summarize the session.