SlideShare a Scribd company logo
Developing Web Applications Using ASP.NET
Objectives


                In this session, you will learn to:
                   Describe user controls and the underlying enabling
                   technologies
                   Create user controls
                   Describe custom Web server controls and the underlying
                   enabling technologies
                   Create Web server controls
                   Describe composite controls and how composite controls are
                   created
                   Create composite Web server controls
                   Describe templated controls and the interfaces that enable
                   their implementation
                   Create templated controls



     Ver. 1.0                                                          Slide 1 of 21
Developing Web Applications Using ASP.NET
User Controls


                A user control usually consists of:
                   A number of Web Server controls and HTML controls
                   Methods and properties to control the interaction between
                   controls included in it
                   Code to handle the user control events
                User controls are created to encapsulate reusable logic for
                Web pages in your application.
                User controls have the following features:
                 • They are saved as files with a .ascx extension.
                 • They can contain code in the .ascx file or use a code-behind
                   file.
                 • They do not contain <html>, <body>, or <form> tags.
                 • They have a <%@Control%> directive instead of <$@Page%>
                   directive.

     Ver. 1.0                                                            Slide 2 of 21
Developing Web Applications Using ASP.NET
User Controls (Contd.)


                   They inherit methods and properties from the
                   System.Web.UI.UserControl class.
                   They have a user interface, usually made up of Web server
                   controls and HTML controls.
                   They can be independently cached for enhanced performance.
                A new user control can be added to a page by right-clicking
                the Web site folder in Solution Explorer and then selecting
                Add New Item.
                The user interface for the new control can be designed by
                using Design view or Source view.
                Event handlers and properties can be written in the
                code-behind file.




     Ver. 1.0                                                         Slide 3 of 21
Developing Web Applications Using ASP.NET
User Controls (Contd.)


                •   If you want to share information between a user control and
                    a page, you can create public properties for the user
                    control.
                •   A user control can be added to a Web page by performing
                    the following steps:
                     • Insert a <%@Register%> directive at the top of the page,
                       underneath the <%@Page%> directive:
                         <%@Register src=“~/controls/productselector.ascx”
                          tagprefix=“AdvWorks” tagname=“productselector” %>
                       Insert the control in to the correct location on the page:
                         <AdvWorks:productselector id=“productSelector1”
                          runat=“server” customProperty=“true”/>




     Ver. 1.0                                                                       Slide 4 of 21
Developing Web Applications Using ASP.NET
Custom Web Server Controls


                Custom Web server controls provide an approach to reuse
                logic in an ASP.NET application.
                Custom Web server controls are:
                • Written entirely by using managed code and have no markup
                  files.
                • Derived from System.Web.UI.Control,
                  System.Web.UI.WebControl, or one of the existing Web
                  server controls included with ASP.NET.
                • Compiled into an assembly before deployment of the
                  application.




     Ver. 1.0                                                        Slide 5 of 21
Developing Web Applications Using ASP.NET
Custom Web Server Controls (Contd.)


                Custom Web server controls are different from User
                controls in the following ways:
                   User controls are easier to create and lay out than Web server
                   controls because they include markup.
                   User controls may introduce delays at run time because
                   controls are not compiled until the page is requested by the
                   first user.
                   Custom Web server controls provide better code security than
                   user controls because they are deployed as compiled
                   assemblies to the server.




     Ver. 1.0                                                            Slide 6 of 21
Developing Web Applications Using ASP.NET
Custom Web Server Controls (Contd.)


                •   Custom Web server controls are written as classes.
                •   The first step to create a custom Web server control is to
                    decide the class from which it will be derived.
                •   If the control is very similar to an existing Web server control,
                    the control can inherit from the Web server control.
                •   If the control will have entirely new functionality, it should
                    inherit from the Control class.
                •   To modify the HTML that is sent to the browser, you typically
                    override the Render method.
                •   While creating a custom Web server control, you can use the
                    App_Code directory to avoid repeated manual compilations.
                •   Once a custom Web server control is created, a developer
                    can add it to the Toolbox, drag it to the design surface, and
                    access its properties and events in the property browser.

     Ver. 1.0                                                               Slide 7 of 21
Developing Web Applications Using ASP.NET
Custom Web Server Controls (Contd.)


                To add a custom Web Server control to a page, you need
                to:
                1. Use one of the following methods to register the control:
                    • Add a <%@Register%> directive to the Web page:
                       <% Register tagPrefix=“AdvWorks”
                         namespace=“AdventureWorks.Controls”%>
                      Add <controls> tag in the Web.config file:
                        <system.web>
                           <pages>
                             <controls>
                                <add tagPrefix =“AdvWorks”
                                 namespace=“AdventureWorks.Controls”/>
                             <controls>
                           <pages>
                        <system.web>


     Ver. 1.0                                                             Slide 8 of 21
Developing Web Applications Using ASP.NET
Custom Web Server Controls (Contd.)


                1. Add the control to the Web page by including the following
                   markup at an appropriate position in the page:
                    <AdvWorks:ProductSelector id=“ProductSelector1
                     runat=“server”/>




     Ver. 1.0                                                            Slide 9 of 21
Developing Web Applications Using ASP.NET
Composite Web Server Controls


                A composite Web server control has the following features:
                • It has a user interface that is composed of several existing
                  Web server controls.
                • It is derived from the
                  System.WebUI.WebControls.CompositeControl class.
                • It creates the child control by overriding the
                  CreateChildControls method.
                • It is compiled into an assembly in the Bin folder before the
                  deployment of the application.




     Ver. 1.0                                                          Slide 10 of 21
Developing Web Applications Using ASP.NET
Composite Web Server Controls (Contd.)


                Comparison with Custom Web Server Controls
                   Like custom Web server controls, a composite Web server
                   control has no mark up fields and is implemented as a class in
                   an assembly.
                   Unlike custom Web server controls, a composite Web server
                   control is composed almost entirely of a combination of
                   existing Web server controls.




     Ver. 1.0                                                            Slide 11 of 21
Developing Web Applications Using ASP.NET
Composite Web Server Controls (Contd.)


                Composite Web server controls are written as classes.
                The creation of composite Web server controls is very
                similar to the way in which you create custom Web server
                controls.
                Composite Web server controls can be compiled into their
                own assemblies or added to assemblies with other controls
                and classes.
                While creating a composite Web server control, you can use
                the App_Code directory to avoid repeated manual
                compilations.




     Ver. 1.0                                                     Slide 12 of 21
Developing Web Applications Using ASP.NET
Composite Web Server Controls (Contd.)


                •   To add a composite Web server control to a Web page, you
                    need to:
                    •   Define a class that derives from
                        System.Web.UI.WebControls.CompositeControl.
                    •   Override the Render method of the class and invoke the
                        RenderControl method of any child control you create.
                    To add a composite Web server control to a Web page, you
                    need to:
                    1. Use one of the following methods to register the control:
                         • Use a <%@register %> directive on the page
                         • Use the <controls> tag in the Web.config file
                    2. Add the control to the page




     Ver. 1.0                                                                 Slide 13 of 21
Developing Web Applications Using ASP.NET
Templated Controls


                A templated control is a special kind of composite control.
                It allows developers to modify the layout of the user
                interface by defining their own templates.
                A templated control is written in the same manner as a
                composite control.
                In addition to the tasks performed for creating a composite
                control, you need to perform the following tasks to create a
                templated control:
                 • Implement one or more properties of the type
                   System.Web.UI.ITemplate.
                 • Expose a public property of type Sysytem.Web.UI.Control
                   (or a derived class) to act as the owner of the template.




     Ver. 1.0                                                        Slide 14 of 21
Developing Web Applications Using ASP.NET
Templated Controls (Contd.)


                You can add a templated control to a Web page in the same
                manner as a composite control.
                You can also specify your own template within the control
                tags to display the data as you wish.




     Ver. 1.0                                                    Slide 15 of 21
Developing Web Applications Using ASP.NET
Demo: Creating Controls for Web Applications


                Problem Statement:
                   You are a developer in the Adventure Works organization, a
                   fictitious bicycle manufacturer. You have been asked to assist
                   in creating a new Business-to-Consumer (B2C) Web
                   application and a related Business-to-Employee (B2E) extranet
                   portal.
                   Decisions on the design of the application have already been
                   made. You have been asked to carry out a number of specific
                   tasks in order to implement various elements of this design. As
                   part of the first phase of the B2C development, you have been
                   asked to develop various controls for the Web application.




     Ver. 1.0                                                            Slide 16 of 21
Developing Web Applications Using ASP.NET
Demo: Creating Controls for Web Applications (Contd.)


                Solution:
                 • To solve this problem, you need to perform following tasks:
                    1. Create User Controls
                        • Open the Adventure Works Web site.
                        • Add a new user control called SiteCompass to the Web site.
                        • Add a label to the SiteCompass user control at design time.
                        • Add code to create controls dynamically for the SiteCompass user
                          control.
                        • Add a property to the SiteCompass user control.
                        • Add the SiteCompass user control to the TopLevel.master master
                          page.
                        • Test the SiteCompass user control.




     Ver. 1.0                                                                      Slide 17 of 21
Developing Web Applications Using ASP.NET
Demo: Creating Controls for Web Applications (Contd.)


                1. Create Web Server Controls
                    a. Add a class file for the custom Web server control.
                    b. Add a private method to the custom Web server control class to update
                       the status displayed to the user.
                    c. Add an override method for RenderContents method of the Web server
                       control.
                    d. Add a public property for the custom Web server control.
                    e. Write code to add the custom Web server control to the page at run
                       time.
                    f. Test the custom Web server control.
                2. Create Composite Web Server Controls
                    a. Modify the custom Web server control to inherit from the Composite
                       Control class.
                    b. Declare and add child controls to the ServiceChecker class.
                    c. Add an event handler for a child control.
                    d. Render the child control.
                    e. Test the composite control.




     Ver. 1.0                                                                     Slide 18 of 21
Developing Web Applications Using ASP.NET
Demo: Creating Controls for Web Applications (Contd.)


                1. Create Templated Controls
                    • Modify the ServiceChecker class to support templates.
                    • Define a default template.
                    • Implement the template logic.
                    • Test the templated control when no template is supplied by the
                      consumer of the control.
                    • Test the templated control when a custom template is supplied by the
                      consumer of the control.




     Ver. 1.0                                                                    Slide 19 of 21
Developing Web Applications Using ASP.NET
Summary


               In this session, you learned that:
                • A user control usually consists of a number of Web server
                  controls and HTML controls, as well as method and properties
                  to control the interaction between these controls.
                • A user control can be added to a page by inserting a <
                  %@Register%> directive at the top of the page and inserting
                  the control at the correct location.
                • Custom Web server controls are written entirely by using
                  managed code and have no markup file.
                • The class created for custom Web server controls is derived
                  from existing Web server controls, or the Control class, .or
                  the WebControl class.




    Ver. 1.0                                                           Slide 20 of 21
Developing Web Applications Using ASP.NET
Summary (Contd.)


               To add a custom Web server control to a page, you need to
               first register the control in the Web page or in the Web.config
               file.
               A composite controls has a user interface that is composed of
               several existing Web server controls.
               The process of creating and adding a composite Web server
               control to a page is similar to the process of adding a custom
               Web server control.
               A templated control is a composite control, that allows a
               developer to change its layout.
               Developers can change the layout of a templated control by
               defining a template for the control.




    Ver. 1.0                                                          Slide 21 of 21
Ad

More Related Content

What's hot (20)

VAST 7.5 and Beyond
VAST 7.5 and BeyondVAST 7.5 and Beyond
VAST 7.5 and Beyond
ESUG
 
"BlackBerry Webworks : Apps for The Smartphone and Tablet"
"BlackBerry Webworks : Apps for The Smartphone and Tablet""BlackBerry Webworks : Apps for The Smartphone and Tablet"
"BlackBerry Webworks : Apps for The Smartphone and Tablet"
Software Park Thailand
 
Creating v sphere client plug ins
Creating v sphere client plug insCreating v sphere client plug ins
Creating v sphere client plug ins
Pablo Roesch
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
Niit Care
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdg
Ziyad Bazed
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
harkesh singh
 
Cordova 3, apps para android
Cordova 3, apps para androidCordova 3, apps para android
Cordova 3, apps para android
Droidcon Spain
 
BlackBerry WebWorks
BlackBerry WebWorksBlackBerry WebWorks
BlackBerry WebWorks
Bhasker Thapan
 
Developing for SP2013
Developing for SP2013Developing for SP2013
Developing for SP2013
Matthias Einig
 
Dynacache in WebSphere Portal Server
Dynacache in WebSphere Portal ServerDynacache in WebSphere Portal Server
Dynacache in WebSphere Portal Server
Rohit Kelapure
 
Presentation on control panel in web hosting
Presentation on control panel in web hostingPresentation on control panel in web hosting
Presentation on control panel in web hosting
SmritiSingh184
 
What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5
Vinayak Tavargeri
 
Administrators manual
Administrators manualAdministrators manual
Administrators manual
ScrumDesk
 
DanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsDanNotes XPages Mobile Controls
DanNotes XPages Mobile Controls
Paul Withers
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1
sumeettechno
 
Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)
Daniel Appelquist
 
AD201 - IBM Domino Application Development Today And Tomorrow
AD201 - IBM Domino Application Development Today And TomorrowAD201 - IBM Domino Application Development Today And Tomorrow
AD201 - IBM Domino Application Development Today And Tomorrow
pjanzen11
 
1812 icap-v1.3 0430
1812 icap-v1.3 04301812 icap-v1.3 0430
1812 icap-v1.3 0430
Rohit Kelapure
 
Revised Adf security in a project centric environment
Revised Adf security in a project centric environmentRevised Adf security in a project centric environment
Revised Adf security in a project centric environment
Jean-Marc Desvaux
 
VAST 7.5 and Beyond
VAST 7.5 and BeyondVAST 7.5 and Beyond
VAST 7.5 and Beyond
ESUG
 
"BlackBerry Webworks : Apps for The Smartphone and Tablet"
"BlackBerry Webworks : Apps for The Smartphone and Tablet""BlackBerry Webworks : Apps for The Smartphone and Tablet"
"BlackBerry Webworks : Apps for The Smartphone and Tablet"
Software Park Thailand
 
Creating v sphere client plug ins
Creating v sphere client plug insCreating v sphere client plug ins
Creating v sphere client plug ins
Pablo Roesch
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
Claudio Procida
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
Niit Care
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdg
Ziyad Bazed
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
harkesh singh
 
Cordova 3, apps para android
Cordova 3, apps para androidCordova 3, apps para android
Cordova 3, apps para android
Droidcon Spain
 
Dynacache in WebSphere Portal Server
Dynacache in WebSphere Portal ServerDynacache in WebSphere Portal Server
Dynacache in WebSphere Portal Server
Rohit Kelapure
 
Presentation on control panel in web hosting
Presentation on control panel in web hostingPresentation on control panel in web hosting
Presentation on control panel in web hosting
SmritiSingh184
 
What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5What's new in Portal and WCM 8.5
What's new in Portal and WCM 8.5
Vinayak Tavargeri
 
Administrators manual
Administrators manualAdministrators manual
Administrators manual
ScrumDesk
 
DanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsDanNotes XPages Mobile Controls
DanNotes XPages Mobile Controls
Paul Withers
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1
sumeettechno
 
Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)
Daniel Appelquist
 
AD201 - IBM Domino Application Development Today And Tomorrow
AD201 - IBM Domino Application Development Today And TomorrowAD201 - IBM Domino Application Development Today And Tomorrow
AD201 - IBM Domino Application Development Today And Tomorrow
pjanzen11
 
Revised Adf security in a project centric environment
Revised Adf security in a project centric environmentRevised Adf security in a project centric environment
Revised Adf security in a project centric environment
Jean-Marc Desvaux
 

Similar to 12 asp.net session17 (20)

03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Niit Care
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Vivek Singh Chandel
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Mani Chaubey
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Niit Care
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Vivek Singh Chandel
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
Raed Aldahdooh
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
parallelminder
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
Rishi Kothari
 
Custom control in asp.net
Custom control in asp.netCustom control in asp.net
Custom control in asp.net
Sireesh K
 
Asp PPT (.NET )
Asp PPT (.NET )Asp PPT (.NET )
Asp PPT (.NET )
Ankit Gupta
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
Synapseindiappsdevelopment
 
MVC 4
MVC 4MVC 4
MVC 4
Vasilios Kuznos
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
ManishaChothe
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
Niit Care
 
Overview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company indiaOverview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company india
Jignesh Aakoliya
 
Client control
Client controlClient control
Client control
Sireesh K
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
Rahul Bansal
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
SHADAB ALI
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
Er. Kamal Bhusal
 
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
SPTechCon
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Niit Care
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Mani Chaubey
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Niit Care
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
Raed Aldahdooh
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
parallelminder
 
Custom control in asp.net
Custom control in asp.netCustom control in asp.net
Custom control in asp.net
Sireesh K
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
ManishaChothe
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
Niit Care
 
Overview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company indiaOverview of ASP.Net by software outsourcing company india
Overview of ASP.Net by software outsourcing company india
Jignesh Aakoliya
 
Client control
Client controlClient control
Client control
Sireesh K
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
Rahul Bansal
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
SHADAB ALI
 
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 4: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
SPTechCon
 
Ad

More from Niit Care (20)

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

Recently uploaded (20)

AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded DevelopersLinux Support for SMARC: How Toradex Empowers Embedded Developers
Linux Support for SMARC: How Toradex Empowers Embedded Developers
Toradex
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 

12 asp.net session17

  • 1. Developing Web Applications Using ASP.NET Objectives In this session, you will learn to: Describe user controls and the underlying enabling technologies Create user controls Describe custom Web server controls and the underlying enabling technologies Create Web server controls Describe composite controls and how composite controls are created Create composite Web server controls Describe templated controls and the interfaces that enable their implementation Create templated controls Ver. 1.0 Slide 1 of 21
  • 2. Developing Web Applications Using ASP.NET User Controls A user control usually consists of: A number of Web Server controls and HTML controls Methods and properties to control the interaction between controls included in it Code to handle the user control events User controls are created to encapsulate reusable logic for Web pages in your application. User controls have the following features: • They are saved as files with a .ascx extension. • They can contain code in the .ascx file or use a code-behind file. • They do not contain <html>, <body>, or <form> tags. • They have a <%@Control%> directive instead of <$@Page%> directive. Ver. 1.0 Slide 2 of 21
  • 3. Developing Web Applications Using ASP.NET User Controls (Contd.) They inherit methods and properties from the System.Web.UI.UserControl class. They have a user interface, usually made up of Web server controls and HTML controls. They can be independently cached for enhanced performance. A new user control can be added to a page by right-clicking the Web site folder in Solution Explorer and then selecting Add New Item. The user interface for the new control can be designed by using Design view or Source view. Event handlers and properties can be written in the code-behind file. Ver. 1.0 Slide 3 of 21
  • 4. Developing Web Applications Using ASP.NET User Controls (Contd.) • If you want to share information between a user control and a page, you can create public properties for the user control. • A user control can be added to a Web page by performing the following steps: • Insert a <%@Register%> directive at the top of the page, underneath the <%@Page%> directive: <%@Register src=“~/controls/productselector.ascx” tagprefix=“AdvWorks” tagname=“productselector” %> Insert the control in to the correct location on the page: <AdvWorks:productselector id=“productSelector1” runat=“server” customProperty=“true”/> Ver. 1.0 Slide 4 of 21
  • 5. Developing Web Applications Using ASP.NET Custom Web Server Controls Custom Web server controls provide an approach to reuse logic in an ASP.NET application. Custom Web server controls are: • Written entirely by using managed code and have no markup files. • Derived from System.Web.UI.Control, System.Web.UI.WebControl, or one of the existing Web server controls included with ASP.NET. • Compiled into an assembly before deployment of the application. Ver. 1.0 Slide 5 of 21
  • 6. Developing Web Applications Using ASP.NET Custom Web Server Controls (Contd.) Custom Web server controls are different from User controls in the following ways: User controls are easier to create and lay out than Web server controls because they include markup. User controls may introduce delays at run time because controls are not compiled until the page is requested by the first user. Custom Web server controls provide better code security than user controls because they are deployed as compiled assemblies to the server. Ver. 1.0 Slide 6 of 21
  • 7. Developing Web Applications Using ASP.NET Custom Web Server Controls (Contd.) • Custom Web server controls are written as classes. • The first step to create a custom Web server control is to decide the class from which it will be derived. • If the control is very similar to an existing Web server control, the control can inherit from the Web server control. • If the control will have entirely new functionality, it should inherit from the Control class. • To modify the HTML that is sent to the browser, you typically override the Render method. • While creating a custom Web server control, you can use the App_Code directory to avoid repeated manual compilations. • Once a custom Web server control is created, a developer can add it to the Toolbox, drag it to the design surface, and access its properties and events in the property browser. Ver. 1.0 Slide 7 of 21
  • 8. Developing Web Applications Using ASP.NET Custom Web Server Controls (Contd.) To add a custom Web Server control to a page, you need to: 1. Use one of the following methods to register the control: • Add a <%@Register%> directive to the Web page: <% Register tagPrefix=“AdvWorks” namespace=“AdventureWorks.Controls”%> Add <controls> tag in the Web.config file: <system.web> <pages> <controls> <add tagPrefix =“AdvWorks” namespace=“AdventureWorks.Controls”/> <controls> <pages> <system.web> Ver. 1.0 Slide 8 of 21
  • 9. Developing Web Applications Using ASP.NET Custom Web Server Controls (Contd.) 1. Add the control to the Web page by including the following markup at an appropriate position in the page: <AdvWorks:ProductSelector id=“ProductSelector1 runat=“server”/> Ver. 1.0 Slide 9 of 21
  • 10. Developing Web Applications Using ASP.NET Composite Web Server Controls A composite Web server control has the following features: • It has a user interface that is composed of several existing Web server controls. • It is derived from the System.WebUI.WebControls.CompositeControl class. • It creates the child control by overriding the CreateChildControls method. • It is compiled into an assembly in the Bin folder before the deployment of the application. Ver. 1.0 Slide 10 of 21
  • 11. Developing Web Applications Using ASP.NET Composite Web Server Controls (Contd.) Comparison with Custom Web Server Controls Like custom Web server controls, a composite Web server control has no mark up fields and is implemented as a class in an assembly. Unlike custom Web server controls, a composite Web server control is composed almost entirely of a combination of existing Web server controls. Ver. 1.0 Slide 11 of 21
  • 12. Developing Web Applications Using ASP.NET Composite Web Server Controls (Contd.) Composite Web server controls are written as classes. The creation of composite Web server controls is very similar to the way in which you create custom Web server controls. Composite Web server controls can be compiled into their own assemblies or added to assemblies with other controls and classes. While creating a composite Web server control, you can use the App_Code directory to avoid repeated manual compilations. Ver. 1.0 Slide 12 of 21
  • 13. Developing Web Applications Using ASP.NET Composite Web Server Controls (Contd.) • To add a composite Web server control to a Web page, you need to: • Define a class that derives from System.Web.UI.WebControls.CompositeControl. • Override the Render method of the class and invoke the RenderControl method of any child control you create. To add a composite Web server control to a Web page, you need to: 1. Use one of the following methods to register the control: • Use a <%@register %> directive on the page • Use the <controls> tag in the Web.config file 2. Add the control to the page Ver. 1.0 Slide 13 of 21
  • 14. Developing Web Applications Using ASP.NET Templated Controls A templated control is a special kind of composite control. It allows developers to modify the layout of the user interface by defining their own templates. A templated control is written in the same manner as a composite control. In addition to the tasks performed for creating a composite control, you need to perform the following tasks to create a templated control: • Implement one or more properties of the type System.Web.UI.ITemplate. • Expose a public property of type Sysytem.Web.UI.Control (or a derived class) to act as the owner of the template. Ver. 1.0 Slide 14 of 21
  • 15. Developing Web Applications Using ASP.NET Templated Controls (Contd.) You can add a templated control to a Web page in the same manner as a composite control. You can also specify your own template within the control tags to display the data as you wish. Ver. 1.0 Slide 15 of 21
  • 16. Developing Web Applications Using ASP.NET Demo: Creating Controls for Web Applications Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in creating a new Business-to-Consumer (B2C) Web application and a related Business-to-Employee (B2E) extranet portal. Decisions on the design of the application have already been made. You have been asked to carry out a number of specific tasks in order to implement various elements of this design. As part of the first phase of the B2C development, you have been asked to develop various controls for the Web application. Ver. 1.0 Slide 16 of 21
  • 17. Developing Web Applications Using ASP.NET Demo: Creating Controls for Web Applications (Contd.) Solution: • To solve this problem, you need to perform following tasks: 1. Create User Controls • Open the Adventure Works Web site. • Add a new user control called SiteCompass to the Web site. • Add a label to the SiteCompass user control at design time. • Add code to create controls dynamically for the SiteCompass user control. • Add a property to the SiteCompass user control. • Add the SiteCompass user control to the TopLevel.master master page. • Test the SiteCompass user control. Ver. 1.0 Slide 17 of 21
  • 18. Developing Web Applications Using ASP.NET Demo: Creating Controls for Web Applications (Contd.) 1. Create Web Server Controls a. Add a class file for the custom Web server control. b. Add a private method to the custom Web server control class to update the status displayed to the user. c. Add an override method for RenderContents method of the Web server control. d. Add a public property for the custom Web server control. e. Write code to add the custom Web server control to the page at run time. f. Test the custom Web server control. 2. Create Composite Web Server Controls a. Modify the custom Web server control to inherit from the Composite Control class. b. Declare and add child controls to the ServiceChecker class. c. Add an event handler for a child control. d. Render the child control. e. Test the composite control. Ver. 1.0 Slide 18 of 21
  • 19. Developing Web Applications Using ASP.NET Demo: Creating Controls for Web Applications (Contd.) 1. Create Templated Controls • Modify the ServiceChecker class to support templates. • Define a default template. • Implement the template logic. • Test the templated control when no template is supplied by the consumer of the control. • Test the templated control when a custom template is supplied by the consumer of the control. Ver. 1.0 Slide 19 of 21
  • 20. Developing Web Applications Using ASP.NET Summary In this session, you learned that: • A user control usually consists of a number of Web server controls and HTML controls, as well as method and properties to control the interaction between these controls. • A user control can be added to a page by inserting a < %@Register%> directive at the top of the page and inserting the control at the correct location. • Custom Web server controls are written entirely by using managed code and have no markup file. • The class created for custom Web server controls is derived from existing Web server controls, or the Control class, .or the WebControl class. Ver. 1.0 Slide 20 of 21
  • 21. Developing Web Applications Using ASP.NET Summary (Contd.) To add a custom Web server control to a page, you need to first register the control in the Web page or in the Web.config file. A composite controls has a user interface that is composed of several existing Web server controls. The process of creating and adding a composite Web server control to a page is similar to the process of adding a custom Web server control. A templated control is a composite control, that allows a developer to change its layout. Developers can change the layout of a templated control by defining a template for the control. Ver. 1.0 Slide 21 of 21