SlideShare ist ein Scribd-Unternehmen logo
1 von 21
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

Weitere ähnliche Inhalte

Was ist angesagt?

VAST 7.5 and Beyond
VAST 7.5 and BeyondVAST 7.5 and Beyond
VAST 7.5 and BeyondESUG
 
"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 insPablo 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 DemystifiedClaudio Procida
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Niit Care
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgZiyad Bazed
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10harkesh singh
 
Cordova 3, apps para android
Cordova 3, apps para androidCordova 3, apps para android
Cordova 3, apps para androidDroidcon Spain
 
Dynacache in WebSphere Portal Server
Dynacache in WebSphere Portal ServerDynacache in WebSphere Portal Server
Dynacache in WebSphere Portal ServerRohit 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 hostingSmritiSingh184
 
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.5Vinayak Tavargeri
 
Administrators manual
Administrators manualAdministrators manual
Administrators manualScrumDesk
 
DanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsDanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsPaul Withers
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1sumeettechno
 
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 Tomorrowpjanzen11
 
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 environmentJean-Marc Desvaux
 

Was ist angesagt? (20)

VAST 7.5 and Beyond
VAST 7.5 and BeyondVAST 7.5 and Beyond
VAST 7.5 and Beyond
 
"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"
 
Creating v sphere client plug ins
Creating v sphere client plug insCreating v sphere client plug ins
Creating v sphere client plug ins
 
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
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
RIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdgRIM Casual Meetup - Bandung #DevIDBdg
RIM Casual Meetup - Bandung #DevIDBdg
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
 
Cordova 3, apps para android
Cordova 3, apps para androidCordova 3, apps para android
Cordova 3, apps para android
 
BlackBerry WebWorks
BlackBerry WebWorksBlackBerry WebWorks
BlackBerry WebWorks
 
Developing for SP2013
Developing for SP2013Developing for SP2013
Developing for SP2013
 
Dynacache in WebSphere Portal Server
Dynacache in WebSphere Portal ServerDynacache in WebSphere Portal Server
Dynacache in WebSphere Portal Server
 
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
 
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
 
Administrators manual
Administrators manualAdministrators manual
Administrators manual
 
DanNotes XPages Mobile Controls
DanNotes XPages Mobile ControlsDanNotes XPages Mobile Controls
DanNotes XPages Mobile Controls
 
Training on webwroks1
Training on webwroks1Training on webwroks1
Training on webwroks1
 
Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)
 
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
 
1812 icap-v1.3 0430
1812 icap-v1.3 04301812 icap-v1.3 0430
1812 icap-v1.3 0430
 
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
 

Ähnlich wie 12 asp.net session17

03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Niit Care
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Vivek chan
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Mani Chaubey
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Niit Care
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Vivek chan
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controlsRaed Aldahdooh
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1parallelminder
 
Custom control in asp.net
Custom control in asp.netCustom control in asp.net
Custom control in asp.netSireesh K
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemoManishaChothe
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20Niit 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 indiaJignesh Aakoliya
 
Client control
Client controlClient control
Client controlSireesh K
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web applicationRahul Bansal
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.netSHADAB 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
 

Ähnlich wie 12 asp.net session17 (20)

03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
 
Custom control in asp.net
Custom control in asp.netCustom control in asp.net
Custom control in asp.net
 
Asp PPT (.NET )
Asp PPT (.NET )Asp PPT (.NET )
Asp PPT (.NET )
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
MVC 4
MVC 4MVC 4
MVC 4
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
 
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
 
Client control
Client controlClient control
Client control
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
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 ...
 

Mehr von 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
 

Kürzlich hochgeladen

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
 
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
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Kürzlich hochgeladen (20)

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
 
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)
 
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
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

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