SlideShare a Scribd company logo
Developing Web Applications Using ASP.NET
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
Objectives
Developing Web Applications Using ASP.NET
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.
User Controls
Developing Web Applications Using ASP.NET
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.
User Controls (Contd.)
Developing Web Applications Using ASP.NET
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”/>
User Controls (Contd.)
Developing Web Applications Using ASP.NET
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.
Custom Web Server Controls
Developing Web Applications Using ASP.NET
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.
Custom Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
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.
Custom Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
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>
Custom Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
2. 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”/>
Custom Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
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.
Composite Web Server Controls
Developing Web Applications Using ASP.NET
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.
Composite Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
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.
Composite Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
To add a composite Web server control to a Web page, you
need to:
1. Define a class that derives from
System.Web.UI.WebControls.CompositeControl.
2. 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
Composite Web Server Controls (Contd.)
Developing Web Applications Using ASP.NET
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.
Templated Controls
Developing Web Applications Using ASP.NET
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.
Templated Controls (Contd.)
Developing Web Applications Using ASP.NET
Problem Statement:
You are a developer in the Adventure Works organization, a
fictitious bicycle manufacturer. You have been asked to assist
in 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.
Demo: Creating Controls for Web Applications
Developing Web Applications Using ASP.NET
Solution:
To solve this problem, you need to perform following tasks:
1. Create User Controls
a. Open the Adventure Works Web site.
b. Add a new user control called SiteCompass to the Web site.
c. Add a label to the SiteCompass user control at design time.
d. Add code to create controls dynamically for the SiteCompass user
control.
e. Add a property to the SiteCompass user control.
f. Add the SiteCompass user control to the TopLevel.master master
page.
g. Test the SiteCompass user control.
Demo: Creating Controls for Web Applications (Contd.)
Developing Web Applications Using ASP.NET
2. 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.
3. 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.
Demo: Creating Controls for Web Applications (Contd.)
Developing Web Applications Using ASP.NET
4. Create Templated Controls
a. Modify the ServiceChecker class to support templates.
b. Define a default template.
c. Implement the template logic.
d. Test the templated control when no template is supplied by the
consumer of the control.
e. Test the templated control when a custom template is supplied by the
consumer of the control.
Demo: Creating Controls for Web Applications (Contd.)
Developing Web Applications Using ASP.NET
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.
Summary
Developing Web Applications Using ASP.NET
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.
Summary (Contd.)

More Related Content

What's hot (20)

ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
Abhishek Sur
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Salesforce Developers
 
Point and Click App Building Workshop
Point and Click App Building WorkshopPoint and Click App Building Workshop
Point and Click App Building Workshop
Salesforce Developers
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
Amelina Ahmeti
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
Raed Aldahdooh
 
Salesforce Lightning Components Workshop
Salesforce Lightning Components WorkshopSalesforce Lightning Components Workshop
Salesforce Lightning Components Workshop
Christophe Coenraets
 
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive FormsAngular 7 Firebase5 CRUD Operations with Reactive Forms
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Digamber Singh
 
Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Devoxx 09 (Belgium)
Devoxx 09 (Belgium)
Roger Kitain
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
baabtra.com - No. 1 supplier of quality freshers
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
Sisir Ghosh
 
ASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server ControlsASP.NET 03 - Working With Web Server Controls
ASP.NET 03 - Working With Web Server Controls
Randy Connolly
 
Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
parallelminder
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Process
wacapps
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
Madhuri Kavade
 
ActionBarCompat Tutorial-Part 1(Prepare and Setup)
ActionBarCompat Tutorial-Part 1(Prepare and Setup)ActionBarCompat Tutorial-Part 1(Prepare and Setup)
ActionBarCompat Tutorial-Part 1(Prepare and Setup)
Haining Lee
 
Rails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 IssueRails Plugins - Linux For You, March 2011 Issue
Rails Plugins - Linux For You, March 2011 Issue
Sagar Arlekar
 
seminar
seminarseminar
seminar
ram007inter
 
jsf2 Notes
jsf2 Notesjsf2 Notes
jsf2 Notes
Rajiv Gupta
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
baabtra.com - No. 1 supplier of quality freshers
 

Viewers also liked (12)

16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
Vivek Singh Chandel
 
07 intel v_tune_session_10
07 intel v_tune_session_1007 intel v_tune_session_10
07 intel v_tune_session_10
Vivek Singh Chandel
 
09 intel v_tune_session_13
09 intel v_tune_session_1309 intel v_tune_session_13
09 intel v_tune_session_13
Vivek Singh Chandel
 
08 asp.net session11
08 asp.net session1108 asp.net session11
08 asp.net session11
Vivek Singh Chandel
 
Net framework session01
Net framework session01Net framework session01
Net framework session01
Vivek Singh Chandel
 
14 asp.net session20
14 asp.net session2014 asp.net session20
14 asp.net session20
Vivek Singh Chandel
 
05 asp.net session07
05 asp.net session0705 asp.net session07
05 asp.net session07
Vivek Singh Chandel
 
Net framework session02
Net framework session02Net framework session02
Net framework session02
Vivek Singh Chandel
 
Wireless Communication via Mobile Phone Using DTMF
Wireless Communication via Mobile Phone Using DTMF Wireless Communication via Mobile Phone Using DTMF
Wireless Communication via Mobile Phone Using DTMF
Vivek Singh Chandel
 
Series Parallel Circuit presentation for schools and kids
Series Parallel Circuit presentation for schools and kidsSeries Parallel Circuit presentation for schools and kids
Series Parallel Circuit presentation for schools and kids
Vivek Singh Chandel
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
Vivek Singh Chandel
 
CyberLab TCP/IP and IP Addressing & Subnetting
CyberLab TCP/IP and IP Addressing & SubnettingCyberLab TCP/IP and IP Addressing & Subnetting
CyberLab TCP/IP and IP Addressing & Subnetting
Vivek Singh Chandel
 

Similar to 12 asp.net session17 (20)

12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Niit Care
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
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
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Niit Care
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Vivek Singh Chandel
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
Terry Yoast
 
Asp PPT (.NET )
Asp PPT (.NET )Asp PPT (.NET )
Asp PPT (.NET )
Ankit Gupta
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
Vivek Singh Chandel
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
harkesh singh
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
Akhil Mittal
 
MVC 4
MVC 4MVC 4
MVC 4
Vasilios Kuznos
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
Er. Kamal Bhusal
 
ASP.NET Interview Questions PDF By ScholarHat
ASP.NET  Interview Questions PDF By ScholarHatASP.NET  Interview Questions PDF By ScholarHat
ASP.NET Interview Questions PDF By ScholarHat
Scholarhat
 
Custom controls
Custom controlsCustom controls
Custom controls
aspnet123
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Niit Care
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
ASP.NET OVERVIEW
ASP.NET OVERVIEWASP.NET OVERVIEW
ASP.NET OVERVIEW
Rishi Kothari
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
Iblesoft
 
Session 1
Session 1Session 1
Session 1
Asif Atick
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Niit Care
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
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
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Niit Care
 
5a329780735625624 ch10
5a329780735625624 ch105a329780735625624 ch10
5a329780735625624 ch10
harkesh singh
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
Akhil Mittal
 
ASP.NET Interview Questions PDF By ScholarHat
ASP.NET  Interview Questions PDF By ScholarHatASP.NET  Interview Questions PDF By ScholarHat
ASP.NET Interview Questions PDF By ScholarHat
Scholarhat
 
Custom controls
Custom controlsCustom controls
Custom controls
aspnet123
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Niit Care
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
Iblesoft
 

More from Vivek Singh Chandel (19)

Deceptive Marketing.pdf
Deceptive Marketing.pdfDeceptive Marketing.pdf
Deceptive Marketing.pdf
Vivek Singh Chandel
 
brain controled wheel chair.pdf
brain controled wheel chair.pdfbrain controled wheel chair.pdf
brain controled wheel chair.pdf
Vivek Singh Chandel
 
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Vivek Singh Chandel
 
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Manav dharma shashtra tatha shashan paddati   munshiram jigyasuManav dharma shashtra tatha shashan paddati   munshiram jigyasu
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Vivek Singh Chandel
 
Self driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking driversSelf driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking drivers
Vivek Singh Chandel
 
EEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using ThoughtsEEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using Thoughts
Vivek Singh Chandel
 
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Vivek Singh Chandel
 
Net framework session03
Net framework session03Net framework session03
Net framework session03
Vivek Singh Chandel
 
04 intel v_tune_session_05
04 intel v_tune_session_0504 intel v_tune_session_05
04 intel v_tune_session_05
Vivek Singh Chandel
 
03 intel v_tune_session_04
03 intel v_tune_session_0403 intel v_tune_session_04
03 intel v_tune_session_04
Vivek Singh Chandel
 
02 intel v_tune_session_02
02 intel v_tune_session_0202 intel v_tune_session_02
02 intel v_tune_session_02
Vivek Singh Chandel
 
01 intel v_tune_session_01
01 intel v_tune_session_0101 intel v_tune_session_01
01 intel v_tune_session_01
Vivek Singh Chandel
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
Vivek Singh Chandel
 
01 asp.net session01
01 asp.net session0101 asp.net session01
01 asp.net session01
Vivek Singh Chandel
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
Vivek Singh Chandel
 
09 asp.net session13
09 asp.net session1309 asp.net session13
09 asp.net session13
Vivek Singh Chandel
 
07 asp.net session10
07 asp.net session1007 asp.net session10
07 asp.net session10
Vivek Singh Chandel
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
Vivek Singh Chandel
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
Vivek Singh Chandel
 
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Mechanism of fullerene synthesis in the ARC REACTOR (Vivek Chan 2013)
Vivek Singh Chandel
 
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Manav dharma shashtra tatha shashan paddati   munshiram jigyasuManav dharma shashtra tatha shashan paddati   munshiram jigyasu
Manav dharma shashtra tatha shashan paddati munshiram jigyasu
Vivek Singh Chandel
 
Self driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking driversSelf driving and connected cars fooling sensors and tracking drivers
Self driving and connected cars fooling sensors and tracking drivers
Vivek Singh Chandel
 
EEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using ThoughtsEEG Acquisition Device to Control Wheelchair Using Thoughts
EEG Acquisition Device to Control Wheelchair Using Thoughts
Vivek Singh Chandel
 
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Full Shri Ramcharitmanas in Hindi Complete With Meaning (Ramayana)
Vivek Singh Chandel
 

Recently uploaded (20)

P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-3-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-3-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdfBiophysics Chapter 3 Methods of Studying Macromolecules.pdf
Biophysics Chapter 3 Methods of Studying Macromolecules.pdf
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
How to track Cost and Revenue using Analytic Accounts in odoo Accounting, App...
Celine George
 
How to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odooHow to Set warnings for invoicing specific customers in odoo
How to Set warnings for invoicing specific customers in odoo
Celine George
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
One Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learningOne Hot encoding a revolution in Machine learning
One Hot encoding a revolution in Machine learning
momer9505
 
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACYUNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
UNIT 3 NATIONAL HEALTH PROGRAMMEE. SOCIAL AND PREVENTIVE PHARMACY
DR.PRISCILLA MARY J
 
Presentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem KayaPresentation of the MIPLM subject matter expert Erdem Kaya
Presentation of the MIPLM subject matter expert Erdem Kaya
MIPLM
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
apa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdfapa-style-referencing-visual-guide-2025.pdf
apa-style-referencing-visual-guide-2025.pdf
Ishika Ghosh
 
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdfExploring-Substances-Acidic-Basic-and-Neutral.pdf
Exploring-Substances-Acidic-Basic-and-Neutral.pdf
Sandeep Swamy
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Metamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative JourneyMetamorphosis: Life's Transformative Journey
Metamorphosis: Life's Transformative Journey
Arshad Shaikh
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
LDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini UpdatesLDMMIA Reiki Master Spring 2025 Mini Updates
LDMMIA Reiki Master Spring 2025 Mini Updates
LDM Mia eStudios
 

12 asp.net session17

  • 1. Developing Web Applications Using ASP.NET 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 Objectives
  • 2. Developing Web Applications Using ASP.NET 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. User Controls
  • 3. Developing Web Applications Using ASP.NET 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. User Controls (Contd.)
  • 4. Developing Web Applications Using ASP.NET 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”/> User Controls (Contd.)
  • 5. Developing Web Applications Using ASP.NET 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. Custom Web Server Controls
  • 6. Developing Web Applications Using ASP.NET 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. Custom Web Server Controls (Contd.)
  • 7. Developing Web Applications Using ASP.NET 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. Custom Web Server Controls (Contd.)
  • 8. Developing Web Applications Using ASP.NET 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> Custom Web Server Controls (Contd.)
  • 9. Developing Web Applications Using ASP.NET 2. 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”/> Custom Web Server Controls (Contd.)
  • 10. Developing Web Applications Using ASP.NET 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. Composite Web Server Controls
  • 11. Developing Web Applications Using ASP.NET 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. Composite Web Server Controls (Contd.)
  • 12. Developing Web Applications Using ASP.NET 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. Composite Web Server Controls (Contd.)
  • 13. Developing Web Applications Using ASP.NET To add a composite Web server control to a Web page, you need to: 1. Define a class that derives from System.Web.UI.WebControls.CompositeControl. 2. 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 Composite Web Server Controls (Contd.)
  • 14. Developing Web Applications Using ASP.NET 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. Templated Controls
  • 15. Developing Web Applications Using ASP.NET 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. Templated Controls (Contd.)
  • 16. Developing Web Applications Using ASP.NET Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in 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. Demo: Creating Controls for Web Applications
  • 17. Developing Web Applications Using ASP.NET Solution: To solve this problem, you need to perform following tasks: 1. Create User Controls a. Open the Adventure Works Web site. b. Add a new user control called SiteCompass to the Web site. c. Add a label to the SiteCompass user control at design time. d. Add code to create controls dynamically for the SiteCompass user control. e. Add a property to the SiteCompass user control. f. Add the SiteCompass user control to the TopLevel.master master page. g. Test the SiteCompass user control. Demo: Creating Controls for Web Applications (Contd.)
  • 18. Developing Web Applications Using ASP.NET 2. 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. 3. 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. Demo: Creating Controls for Web Applications (Contd.)
  • 19. Developing Web Applications Using ASP.NET 4. Create Templated Controls a. Modify the ServiceChecker class to support templates. b. Define a default template. c. Implement the template logic. d. Test the templated control when no template is supplied by the consumer of the control. e. Test the templated control when a custom template is supplied by the consumer of the control. Demo: Creating Controls for Web Applications (Contd.)
  • 20. Developing Web Applications Using ASP.NET 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. Summary
  • 21. Developing Web Applications Using ASP.NET 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. Summary (Contd.)