SlideShare a Scribd company logo
1 of 26
Slide 1 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
In this session, you will learn to:
Explain the differences between HTML controls and Web
server controls
Describe the different types of Web server controls
Explain how to use HTML controls and Web server controls
Explain how the postback model of ASP.NET 2.0 works
Create Web-based user interfaces with HTML controls and
Web server controls
Write code that interacts with Web server controls
Write code that interacts with the postback model of ASP.NET
2.0
Objectives
Slide 2 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
HTML Controls:
HTML controls are used to add static HTML elements to a Web
page.
By default, HTML controls are not accessible to the server-side
code in the Web page.
To enable your server-side code to interact with HTML
controls, you must specify that the control runs on the server.
Web Server Controls:
Web Server controls are .NET Framework objects that are
converted by ASP.NET to HTML elements at run time.
On receiving a request for a Web page containing Web server
controls, ASP.NET :
Generates HTML output based on the Web server controls.
Returns the HTML output to the browser.
HTML Controls and Web Server Controls
Slide 3 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Difference between HTML controls and Web server
controls:
Web Server controls are more versatile than HTML controls if
you wish to run server-side code associated with controls.
Web Server controls incur more overhead when processing the
page as compared to HTML controls.
Web Server controls support a rich programming model as
compared to their HTML equivalents.
HTML Controls and Web Server Controls (Contd.)
Slide 4 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Visual Studio 2005 groups Web server controls together in
the Toolbox, based on their functionality.
The various groups of controls are:
Standard Controls
Data Controls
Validation Controls
Navigation Controls
Login Controls
WebPart Controls
Types of Web Server Controls
Slide 5 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Standard Controls:
This group contains controls that provide common user
interface elements.
Standard controls include:
TextBox
ListBox
DropDownList
Checkbox
RadioButton
Button
Image
Table
Calendar
Types of Web Server Controls (Contd.)
Standard Controls
Slide 6 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Data Controls:
This group contains controls used to manipulate data stored in
databases, XML files, and other .NET Framework objects.
Data controls include:
Grid View
SqlDataSource
Types of Web Server Controls (Contd.)
Data Controls
Slide 7 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Validation Controls:
This group contains controls that are used to validate user
input.
Simple validation is done on the client side by generating
JavaScript code. This reduces the load on the Web server and
improves responsiveness.
Complex validation is done on the Web server.
Validation controls include:
RequiredFieldValidator
CompareValidator
Types of Web Server Controls (Contd.)
Validation Controls
Slide 8 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Navigation Controls:
The controls in this group are used to enable the user to move
through the Web site.
Navigation controls include:
Menu
TreeView
SiteMapPath
Types of Web Server Controls (Contd.)
Navigation Controls
Slide 9 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Login Controls:
The controls in this group are used to create login and sign-up
pages for your Web sites.
Login controls include:
Login
ChangePassword
PasswordRecovery
Types of Web Server Controls (Contd.)
Login Controls
Slide 10 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
WebPart Controls:
The controls in this group can be used to build the framework
for dynamic Web pages.
These controls are typically used in portal-type Web
applications.
WebPart controls include:
WebPartManager
WebPartZone
Types of Web Server Controls (Contd.)
Web Part Controls
Slide 11 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Methods for adding Web server controls to Web forms:
Drag and drop the control from the Toolbox onto the Design
view of the Web page.
Drag and drop the control from the Toolbox into the Source
view of the Web page.
Type the markup text for the control directly into the Source
view of the Web page.
Working with Web Server Controls
Slide 12 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Methods for Setting Web Server Control Properties at
Design Time:
Select the control in the Design view and set the property
values in the Properties window.
Select the markup text for the control in the Source view and
set the property values in the Properties window.
Edit the markup text for the control directly in the Source view
of the Web page.
Working with Web Server Controls (Contd.)
Slide 13 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
You can manipulate Web server controls at run time by:
Setting a writable property
Invoking a method
Reading a readable property
//Set a writable property
Textbox1.Text = “Hello World!”;
//Invoke a method
TextBox1.Focus();
//Reading a readable property
string sName = TextBox1.Text
Working with Web Server Controls (Contd.)
Slide 14 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Postback model provides a mechanism for:
Sending control properties on Web pages from the Web
browser to the Web server.
Restoring the values when a response is sent back from the
Web server to the Web browser.
This model enables Web server controls to retain their
values over multiple requests to the server.
It enables you to develop Web pages as if they are part of a
stateful application.
The ASP.NET 2.0 Page Postback Model
Slide 15 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
AutoPostBack Property:
Some Web server controls support the AutoPostBack
property.
This property controls whether user interaction with the control
should invoke a round-trip request to the server.
EnableViewState Property:
This property determines whether the control should retain its
state for the duration of the postback.
This property should be set to true for those controls whose
properties are set in server-side code.
The ASP.NET 2.0 Page Postback Model (Contd.)
Slide 16 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
By default, buttons and other controls that cause a postback
on a Web page submit the page back to itself.
Controls can be configured to post to a different target page.
To enable cross-page posting, you need to set the
PostBackURL property of a control to the URL of the target
page.
To retrieve control values on the submitting page from the
target page, you can use the Page.PreviousPage object.
To retrieve the public properties on the submitting page
from the target page, you need to include the
PreviousPageType directive in the target page as:
<%@ PreviousPageType VirtualPath=
“~/SourcePage.aspx” %>
Cross-Page Posting in an ASP.NET Web Page
Slide 17 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
A Web page can be invoked in a variety of ways:
By an original request
By a postback
By a cross-page post from another page
By transfer from another page by using the Server.Transfer
method
To determine how a page was invoked, you can examine the
following properties of the Page object:
Page.IsPostBack: This property is true when page is invoked
by a postback page and false otherwise.
Page.PreviousPage: This property contains a reference to the
source page when the page is invoked by either a cross page
posting or a server transfer. In all other cases, it contains Null.
Page.PreviousPage.IsCrossPagePostBack: This property
is true when the page is invoked by a cross page posting.
Determine How an ASP.NET Web Page Was
Invoked
Slide 18 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Use the Button.OnClientClick property to specify
client-side script to be run when the Button object is
clicked.
The code that you add to this property is added to the
onclick attribute of the control.
The Button.OnClientClick Property
Slide 19 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Problem Statement:
You are a developer in the Adventure Works organization, a
fictitious bicycle manufacturer. You have been asked to assist
in the development of the Business-to-Consumer (B2C) Web
application and a related Business-to-Employee (B2E) extranet
portal.
Decisions on the design of the application have already been
taken. You have been asked to carry out a number of specific
tasks to implement various elements of this design.
Demo: Adding and Configuring Server Controls
Slide 20 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
As part of the first phase of the B2C development, you have
been asked to complete the prototypes for the following pages:
Survey.aspx. You will design a rich graphical user interface for this
page that enables users to submit responses to an online survey.
You will also add a SiteMapPath control to this page to aid user
navigation.
SurveyReceipt.aspx. You will design this page to receive the
information provided by the user in the Survey.aspx page.
FeedbackForm.aspx. You will design this page to receive the
information provided by the user in the existing Feedback.aspx
page.
Default.aspx. You will add a Menu control to this page to aid user
navigation.
Demo: Adding and Configuring Server Controls (Contd.)
Slide 21 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
You will also add and review a Web.sitemap file that will be
used to add navigation features to the Web application.
Additionally, you will add and review an advertising schedule
file that will be used to add dynamic image display features to
the Web application.
Demo: Adding and Configuring Server Controls (Contd.)
Slide 22 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
Solution:
To solve this problem, you need to perform the following tasks:
1. Build the Graphical User Interfaces with HTML Controls
a. Review the proposed design of the Survey.aspx page.
b. Open the Adventure Works Web site.
c. Define the Survey.aspx page layout by using HTML controls in Design view.
d. Define the Survey.aspx page layout by modifying HTML markup in Source
view.
e. Add HTML Input controls to the Web page.
Demo: Adding and Configuring Server Controls (Contd.)
Slide 23 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
2. Build Graphical User Interfaces with Web Server Controls
a. Review the proposed design of the Survey.aspx page.
b. Refine the Survey.aspx page layout by using an ASP.NET Table Web server
control in Design view.
c. Modify the properties of the Table Web server control.
d. Add rows to the Table Web Server control by using Source view.
e. Add a nested Table Web server control in Source view.
f. Add Web server controls to the Table control.
g. Add site navigation functionality by using Web server controls.
h. Incorporate advertising functionality with Web server controls.
Demo: Adding and Configuring Server Controls (Contd.)
Slide 24 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
3. Program Web Server Controls and Work with Postbacks
a. Manage the Click event for the ImageMap object.
b. Create the OnClientClick property and the server-side Click event for
the Submit button.
c. Determine if an ASP.NET Web page was invoked as part of the postback
process.
d. Create a page that can receive and process information submitted as part of a
cross-page postback.
e. Test the Web application.
Demo: Adding and Configuring Server Controls (Contd.)
Slide 25 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
In this session, you learned that:
HTML controls are representations of HTML markup which are
not accessible to the server side code.
Web server controls are .NET Framework objects that are
converted by ASP.NET to HTML elements at run time.
Visual Studio 2005 provides many groups of Web server
controls based on their functionality, such as Standard Controls
and Data Controls.
You can add Web server controls to Web forms from the
Toolbox or by typing markup text.
You can set Web server control properties at design time as
well at run time.
The ASP.NET postback model is designed to provide stateful
rendering of dynamic content on a Web page.
Summary
Slide 26 of 26Ver. 1.0
Developing Web Applications Using ASP.NET
The Page object exposes the IsPostBack property that you
can use to determine how a page was invoked.
You can configure the controls to post to a different target page
referred to as cross-page posting.
When a page is invoked by another page, you can retrieve
control values and public properties of the invoking page from
the invoked page.
Summary (Contd.)

More Related Content

What's hot (20)

Parallelminds.asp.net with sp
Parallelminds.asp.net with spParallelminds.asp.net with sp
Parallelminds.asp.net with sp
 
Asp PPT (.NET )
Asp PPT (.NET )Asp PPT (.NET )
Asp PPT (.NET )
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
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
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
Controls in asp.net
Controls in asp.netControls in asp.net
Controls in asp.net
 
Standard control in asp.net
Standard control in asp.netStandard control in asp.net
Standard control in asp.net
 
Controls
ControlsControls
Controls
 
ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828ASP.NET User Controls - 20090828
ASP.NET User Controls - 20090828
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
Asp.net html server control
Asp.net html  server controlAsp.net html  server control
Asp.net html server control
 
seminar
seminarseminar
seminar
 
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 ...
 
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
 
Ajaxppt
AjaxpptAjaxppt
Ajaxppt
 
Chapter 09
Chapter 09Chapter 09
Chapter 09
 
ASP.NET 4.0 Roadmap
ASP.NET 4.0 RoadmapASP.NET 4.0 Roadmap
ASP.NET 4.0 Roadmap
 

Viewers also liked

2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience
2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience
2013-02-25 to 2013-03-28 - Summative Evaluation of Field ExperienceDaniel Genesee
 
20151105_Infoday RS1_Juan Catret
20151105_Infoday RS1_Juan Catret20151105_Infoday RS1_Juan Catret
20151105_Infoday RS1_Juan CatretRedit
 
Varför har vi påskkärringar
Varför har vi påskkärringar Varför har vi påskkärringar
Varför har vi påskkärringar ceciliahasselberg
 
Herramientas teóricas, metodológicas para la negociación,
Herramientas teóricas, metodológicas para la negociación,Herramientas teóricas, metodológicas para la negociación,
Herramientas teóricas, metodológicas para la negociación,ivelisaardilaromero
 
Regionale 16 _communique_de_presse
Regionale 16 _communique_de_presseRegionale 16 _communique_de_presse
Regionale 16 _communique_de_presseBâle Région Mag
 
Week 7 Commodity Crops and CAFOs
Week 7   Commodity Crops and CAFOsWeek 7   Commodity Crops and CAFOs
Week 7 Commodity Crops and CAFOsJenSantry
 
La Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativas
La Fotografia Artistica De Bodas - Cuestiones Positivas Y NegativasLa Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativas
La Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativasjosegalans60
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05Mani Chaubey
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Mani Chaubey
 
Lebenslauf Tamer El-Sendiony (3)
Lebenslauf Tamer El-Sendiony (3)Lebenslauf Tamer El-Sendiony (3)
Lebenslauf Tamer El-Sendiony (3)Tamer Mahmoud
 

Viewers also liked (17)

2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience
2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience
2013-02-25 to 2013-03-28 - Summative Evaluation of Field Experience
 
20151105_Infoday RS1_Juan Catret
20151105_Infoday RS1_Juan Catret20151105_Infoday RS1_Juan Catret
20151105_Infoday RS1_Juan Catret
 
Seminario n° 2
Seminario n° 2Seminario n° 2
Seminario n° 2
 
IDENTITIES
IDENTITIESIDENTITIES
IDENTITIES
 
Varför har vi påskkärringar
Varför har vi påskkärringar Varför har vi påskkärringar
Varför har vi påskkärringar
 
Herramientas teóricas, metodológicas para la negociación,
Herramientas teóricas, metodológicas para la negociación,Herramientas teóricas, metodológicas para la negociación,
Herramientas teóricas, metodológicas para la negociación,
 
Regionale 16 _communique_de_presse
Regionale 16 _communique_de_presseRegionale 16 _communique_de_presse
Regionale 16 _communique_de_presse
 
Geometrie non euclide
Geometrie non euclideGeometrie non euclide
Geometrie non euclide
 
Week 7 Commodity Crops and CAFOs
Week 7   Commodity Crops and CAFOsWeek 7   Commodity Crops and CAFOs
Week 7 Commodity Crops and CAFOs
 
portada scratch
portada scratchportada scratch
portada scratch
 
Enfermagem 2015
Enfermagem 2015Enfermagem 2015
Enfermagem 2015
 
Ubuntu
UbuntuUbuntu
Ubuntu
 
La Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativas
La Fotografia Artistica De Bodas - Cuestiones Positivas Y NegativasLa Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativas
La Fotografia Artistica De Bodas - Cuestiones Positivas Y Negativas
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
Lebenslauf Tamer El-Sendiony (3)
Lebenslauf Tamer El-Sendiony (3)Lebenslauf Tamer El-Sendiony (3)
Lebenslauf Tamer El-Sendiony (3)
 
Reji 0315
Reji 0315Reji 0315
Reji 0315
 

Similar to 03 asp.net session04

03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04Niit Care
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1parallelminder
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Vivek chan
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17Niit Care
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Niit Care
 
Asp.Net Page Life
Asp.Net Page LifeAsp.Net Page Life
Asp.Net Page Lifeguest812990
 
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 questionsAkhil Mittal
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02Vivek chan
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08Mani Chaubey
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23Niit Care
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Niit Care
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemoManishaChothe
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentChui-Wen Chiu
 
Foundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docxFoundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docxhanneloremccaffery
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Vivek chan
 

Similar to 03 asp.net session04 (20)

03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Parallelminds.web partdemo1
Parallelminds.web partdemo1Parallelminds.web partdemo1
Parallelminds.web partdemo1
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Asp.Net Page Life
Asp.Net Page LifeAsp.Net Page Life
Asp.Net Page Life
 
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
 
02 asp.net session02
02 asp.net session0202 asp.net session02
02 asp.net session02
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 
16 asp.net session23
16 asp.net session2316 asp.net session23
16 asp.net session23
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
Parallelminds.web partdemo
Parallelminds.web partdemoParallelminds.web partdemo
Parallelminds.web partdemo
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
 
Asp.Net Ajax Component Development
Asp.Net Ajax Component DevelopmentAsp.Net Ajax Component Development
Asp.Net Ajax Component Development
 
Foundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docxFoundation and PathwaysCOS10020 Creating Web Application.docx
Foundation and PathwaysCOS10020 Creating Web Application.docx
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 

03 asp.net session04

  • 1. Slide 1 of 26Ver. 1.0 Developing Web Applications Using ASP.NET In this session, you will learn to: Explain the differences between HTML controls and Web server controls Describe the different types of Web server controls Explain how to use HTML controls and Web server controls Explain how the postback model of ASP.NET 2.0 works Create Web-based user interfaces with HTML controls and Web server controls Write code that interacts with Web server controls Write code that interacts with the postback model of ASP.NET 2.0 Objectives
  • 2. Slide 2 of 26Ver. 1.0 Developing Web Applications Using ASP.NET HTML Controls: HTML controls are used to add static HTML elements to a Web page. By default, HTML controls are not accessible to the server-side code in the Web page. To enable your server-side code to interact with HTML controls, you must specify that the control runs on the server. Web Server Controls: Web Server controls are .NET Framework objects that are converted by ASP.NET to HTML elements at run time. On receiving a request for a Web page containing Web server controls, ASP.NET : Generates HTML output based on the Web server controls. Returns the HTML output to the browser. HTML Controls and Web Server Controls
  • 3. Slide 3 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Difference between HTML controls and Web server controls: Web Server controls are more versatile than HTML controls if you wish to run server-side code associated with controls. Web Server controls incur more overhead when processing the page as compared to HTML controls. Web Server controls support a rich programming model as compared to their HTML equivalents. HTML Controls and Web Server Controls (Contd.)
  • 4. Slide 4 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Visual Studio 2005 groups Web server controls together in the Toolbox, based on their functionality. The various groups of controls are: Standard Controls Data Controls Validation Controls Navigation Controls Login Controls WebPart Controls Types of Web Server Controls
  • 5. Slide 5 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Standard Controls: This group contains controls that provide common user interface elements. Standard controls include: TextBox ListBox DropDownList Checkbox RadioButton Button Image Table Calendar Types of Web Server Controls (Contd.) Standard Controls
  • 6. Slide 6 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Data Controls: This group contains controls used to manipulate data stored in databases, XML files, and other .NET Framework objects. Data controls include: Grid View SqlDataSource Types of Web Server Controls (Contd.) Data Controls
  • 7. Slide 7 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Validation Controls: This group contains controls that are used to validate user input. Simple validation is done on the client side by generating JavaScript code. This reduces the load on the Web server and improves responsiveness. Complex validation is done on the Web server. Validation controls include: RequiredFieldValidator CompareValidator Types of Web Server Controls (Contd.) Validation Controls
  • 8. Slide 8 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Navigation Controls: The controls in this group are used to enable the user to move through the Web site. Navigation controls include: Menu TreeView SiteMapPath Types of Web Server Controls (Contd.) Navigation Controls
  • 9. Slide 9 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Login Controls: The controls in this group are used to create login and sign-up pages for your Web sites. Login controls include: Login ChangePassword PasswordRecovery Types of Web Server Controls (Contd.) Login Controls
  • 10. Slide 10 of 26Ver. 1.0 Developing Web Applications Using ASP.NET WebPart Controls: The controls in this group can be used to build the framework for dynamic Web pages. These controls are typically used in portal-type Web applications. WebPart controls include: WebPartManager WebPartZone Types of Web Server Controls (Contd.) Web Part Controls
  • 11. Slide 11 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Methods for adding Web server controls to Web forms: Drag and drop the control from the Toolbox onto the Design view of the Web page. Drag and drop the control from the Toolbox into the Source view of the Web page. Type the markup text for the control directly into the Source view of the Web page. Working with Web Server Controls
  • 12. Slide 12 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Methods for Setting Web Server Control Properties at Design Time: Select the control in the Design view and set the property values in the Properties window. Select the markup text for the control in the Source view and set the property values in the Properties window. Edit the markup text for the control directly in the Source view of the Web page. Working with Web Server Controls (Contd.)
  • 13. Slide 13 of 26Ver. 1.0 Developing Web Applications Using ASP.NET You can manipulate Web server controls at run time by: Setting a writable property Invoking a method Reading a readable property //Set a writable property Textbox1.Text = “Hello World!”; //Invoke a method TextBox1.Focus(); //Reading a readable property string sName = TextBox1.Text Working with Web Server Controls (Contd.)
  • 14. Slide 14 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Postback model provides a mechanism for: Sending control properties on Web pages from the Web browser to the Web server. Restoring the values when a response is sent back from the Web server to the Web browser. This model enables Web server controls to retain their values over multiple requests to the server. It enables you to develop Web pages as if they are part of a stateful application. The ASP.NET 2.0 Page Postback Model
  • 15. Slide 15 of 26Ver. 1.0 Developing Web Applications Using ASP.NET AutoPostBack Property: Some Web server controls support the AutoPostBack property. This property controls whether user interaction with the control should invoke a round-trip request to the server. EnableViewState Property: This property determines whether the control should retain its state for the duration of the postback. This property should be set to true for those controls whose properties are set in server-side code. The ASP.NET 2.0 Page Postback Model (Contd.)
  • 16. Slide 16 of 26Ver. 1.0 Developing Web Applications Using ASP.NET By default, buttons and other controls that cause a postback on a Web page submit the page back to itself. Controls can be configured to post to a different target page. To enable cross-page posting, you need to set the PostBackURL property of a control to the URL of the target page. To retrieve control values on the submitting page from the target page, you can use the Page.PreviousPage object. To retrieve the public properties on the submitting page from the target page, you need to include the PreviousPageType directive in the target page as: <%@ PreviousPageType VirtualPath= “~/SourcePage.aspx” %> Cross-Page Posting in an ASP.NET Web Page
  • 17. Slide 17 of 26Ver. 1.0 Developing Web Applications Using ASP.NET A Web page can be invoked in a variety of ways: By an original request By a postback By a cross-page post from another page By transfer from another page by using the Server.Transfer method To determine how a page was invoked, you can examine the following properties of the Page object: Page.IsPostBack: This property is true when page is invoked by a postback page and false otherwise. Page.PreviousPage: This property contains a reference to the source page when the page is invoked by either a cross page posting or a server transfer. In all other cases, it contains Null. Page.PreviousPage.IsCrossPagePostBack: This property is true when the page is invoked by a cross page posting. Determine How an ASP.NET Web Page Was Invoked
  • 18. Slide 18 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Use the Button.OnClientClick property to specify client-side script to be run when the Button object is clicked. The code that you add to this property is added to the onclick attribute of the control. The Button.OnClientClick Property
  • 19. Slide 19 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Problem Statement: You are a developer in the Adventure Works organization, a fictitious bicycle manufacturer. You have been asked to assist in the development of the Business-to-Consumer (B2C) Web application and a related Business-to-Employee (B2E) extranet portal. Decisions on the design of the application have already been taken. You have been asked to carry out a number of specific tasks to implement various elements of this design. Demo: Adding and Configuring Server Controls
  • 20. Slide 20 of 26Ver. 1.0 Developing Web Applications Using ASP.NET As part of the first phase of the B2C development, you have been asked to complete the prototypes for the following pages: Survey.aspx. You will design a rich graphical user interface for this page that enables users to submit responses to an online survey. You will also add a SiteMapPath control to this page to aid user navigation. SurveyReceipt.aspx. You will design this page to receive the information provided by the user in the Survey.aspx page. FeedbackForm.aspx. You will design this page to receive the information provided by the user in the existing Feedback.aspx page. Default.aspx. You will add a Menu control to this page to aid user navigation. Demo: Adding and Configuring Server Controls (Contd.)
  • 21. Slide 21 of 26Ver. 1.0 Developing Web Applications Using ASP.NET You will also add and review a Web.sitemap file that will be used to add navigation features to the Web application. Additionally, you will add and review an advertising schedule file that will be used to add dynamic image display features to the Web application. Demo: Adding and Configuring Server Controls (Contd.)
  • 22. Slide 22 of 26Ver. 1.0 Developing Web Applications Using ASP.NET Solution: To solve this problem, you need to perform the following tasks: 1. Build the Graphical User Interfaces with HTML Controls a. Review the proposed design of the Survey.aspx page. b. Open the Adventure Works Web site. c. Define the Survey.aspx page layout by using HTML controls in Design view. d. Define the Survey.aspx page layout by modifying HTML markup in Source view. e. Add HTML Input controls to the Web page. Demo: Adding and Configuring Server Controls (Contd.)
  • 23. Slide 23 of 26Ver. 1.0 Developing Web Applications Using ASP.NET 2. Build Graphical User Interfaces with Web Server Controls a. Review the proposed design of the Survey.aspx page. b. Refine the Survey.aspx page layout by using an ASP.NET Table Web server control in Design view. c. Modify the properties of the Table Web server control. d. Add rows to the Table Web Server control by using Source view. e. Add a nested Table Web server control in Source view. f. Add Web server controls to the Table control. g. Add site navigation functionality by using Web server controls. h. Incorporate advertising functionality with Web server controls. Demo: Adding and Configuring Server Controls (Contd.)
  • 24. Slide 24 of 26Ver. 1.0 Developing Web Applications Using ASP.NET 3. Program Web Server Controls and Work with Postbacks a. Manage the Click event for the ImageMap object. b. Create the OnClientClick property and the server-side Click event for the Submit button. c. Determine if an ASP.NET Web page was invoked as part of the postback process. d. Create a page that can receive and process information submitted as part of a cross-page postback. e. Test the Web application. Demo: Adding and Configuring Server Controls (Contd.)
  • 25. Slide 25 of 26Ver. 1.0 Developing Web Applications Using ASP.NET In this session, you learned that: HTML controls are representations of HTML markup which are not accessible to the server side code. Web server controls are .NET Framework objects that are converted by ASP.NET to HTML elements at run time. Visual Studio 2005 provides many groups of Web server controls based on their functionality, such as Standard Controls and Data Controls. You can add Web server controls to Web forms from the Toolbox or by typing markup text. You can set Web server control properties at design time as well at run time. The ASP.NET postback model is designed to provide stateful rendering of dynamic content on a Web page. Summary
  • 26. Slide 26 of 26Ver. 1.0 Developing Web Applications Using ASP.NET The Page object exposes the IsPostBack property that you can use to determine how a page was invoked. You can configure the controls to post to a different target page referred to as cross-page posting. When a page is invoked by another page, you can retrieve control values and public properties of the invoking page from the invoked page. Summary (Contd.)

Editor's Notes

  1. Show all the controls using visual studio and discuss the use of few controls.
  2. Show all the controls using visual studio and discuss the use of few controls.
  3. Show all the controls using visual studio and discuss the use of few controls.
  4. Show all the controls using visual studio and discuss the use of few controls.
  5. Show all the controls using visual studio and discuss the use of few controls.
  6. Show all the controls using visual studio and discuss the use of few controls.
  7. Show all the controls using visual studio and discuss the use of few controls. Discuss HTML Server conrols
  8. Web Server controls are automatically configured with the runat=&amp;quot;server&amp;quot; attribute, so there is no need to convert them as there is for HTML server controls. Edit the ID attribute that Visual Studio automatically assigns.
  9. Show the demo by performing each step to set Web server control properties Explain by example how to manipulate Web server control (refer SG)
  10. Show the demo by performing each step to set Web server control properties Explain by example how to manipulate Web server control (refer SG)
  11. FAQ Explain the HTTP is state less protocol it does not store any reference of previous request even with the same user. Server has to maintain such information pragmatically. Explain how round trip processing maintain this state.
  12. Explain with example of ListBox and DropDownList control given SG in Auto Postback Discuss when we set EnableViewState Property to true Explain the difference between postback on self page and postback on crosspage
  13. Explain what is server transfer invocation what is Original Request invocation Show the use of these properties by using the example given in SG.
  14. Explain what is server transfer invocation what is Original Request invocation Show the use of these properties by using the example given in SG.
  15. Explain what is server transfer invocation what is Original Request invocation Show the use of these properties by using the example given in SG.