SlideShare a Scribd company logo
• Understanding Ajax
• Advantages & Disadvantages of Ajax
• The Script Manager
• Update Panel
• Partial Updates
• Conditional Updates
• Triggers
• Progress Notification
• Timed Refreshes
• ASP.NET AJAX Control Toolkit
Ajax is programming shorthand for a set of techniques
that create more responsive, dynamic pages that refresh
themselves quickly and flicker-free.

One of the hallmarks of Ajax is the ability to refresh part
of the page while leaving the rest untouched.

Technically, it’s a short form for Asynchronous JavaScript
and XML, although this technique is now considered to
be just one of several possible characteristics of an Ajax
web application.
• The key benefit of Ajax is responsiveness because it
  can react immediately updating the page
  partially, leaving the unchanged portion untouched

• An Ajax application, when done properly, provides a
  better flicker free experience for the user.




• Complexity
• Browser Support
In order to use ASP.NET AJAX, you need to place the ScriptManager
control on your webpage.

It adds the links to the ASP.NET AJAX JavaScript libraries. It does that
by inserting a script block
<script src="/YourWebSite/ScriptResource.axd?d=RUSU1mI ..."
type="text/javascript">
</script>

ScriptResource.axd is a resource that tells ASP.NET to find a
JavaScript file that’s embedded in one of the compiled .NET 4
assemblies.

The JavaScript file is only downloaded once, and then cached by the
browser so it can be used by various pages in the website.
ASP.NET includes a handy control called UpdatePanel that lets
you take an ordinary page with server-side logic and make sure
it refreshes itself in flicker-free Ajax style using partial updates.

The basic idea is that you divide your web page into one or more
distinct regions, each of which is wrapped inside an invisible
UpdatePanel.

When an event occurs in a control that’s located inside an
UpdatePanel, and this event would normally trigger a full-page
postback, the UpdatePanel intercepts the event and performs an
asynchronous callback instead.

The only difference is the means of communication (the page
uses an asynchronous call to get the new data) and the way the
received data is dealt with (the UpdatePanel refreshes its inner
content, but the remainder of the page is not changed).
1. The user clicks a button inside an UpdatePanel.

2. The UpdatePanel intercepts the client-side click.
Now, ASP.NET AJAX performs a callback to the server
instead of a full-page postback.

3. On the server, normal page life cycle executes, with all
the usual events. Finally, the page is rendered to HTML
and returned to the browser.

4. ASP.NET AJAX receives HTML content for every
UpdatePanel on the page. The client-side script code
then updates the page, replacing the existing HTML that’s
in each panel with the new content. (If a change has
occurred to content that’s not inside an UpdatePanel, it’s
ignored.)
The key technique in an Ajax web application is
partial refreshes.

With partial refreshes, the entire page doesn’t
need to be posted back and refreshed in the
browser.

The request takes place in the background, so
the webpage remains responsive.

When the web page receives the response, it
updates just the changed portion of the page,
Chapter 25
In complex pages, you might have more than one
UpdatePanel. In this case, when one UpdatePanel
triggers an update, all the UpdatePanel regions will be
refreshed.

In this situation, you can configure the panels to update
themselves independently. Simply change the
UpdatePanel.UpdateMode property from Always to
Conditional.

The UpdatePanel will refresh itself only if an event
occurs in one of the controls in that UpdatePanel.
If you move the controls that fire postback out of the
UpdatePanel, their events won’t be intercepted any
longer, and they’ll trigger full-page postbacks with the
familiar flicker.

The solution is to explicitly tell the UpdatePanel to
monitor those controls, even though they aren’t
inside the UpdatePanel. You can do this by adding
triggers to the UpdatePanel.

Just select the UpdatePanel, click the Triggers property
in the Properties window, and click the ellipsis (...) that
appears in the Triggers box. Visual Studio will open a
dialog box where you can add as many triggers as you
want, and pick the control for each trigger from a drop-
down list.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Font-
Bold="True"></asp:Label>
<br />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=“cmdPostBack" />
</Triggers>
</asp:UpdatePanel>


<asp:Button ID="cmdPostback" runat="server" Text="Refresh Full
Page" />
ASP.NET includes UpdateProgress control that allows
you to show a message while a time-consuming
asynchronous request is under way.

The UpdateProgress control works in conjunction with
the UpdatePanel.

When you add the UpdateProgress control to a
page, you get the ability to specify some content that will
appear as soon as an asynchronous request is started
and disappear as soon as the request is finished.

This content can include a fixed message, but many
people prefer to use an animated GIF
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div style="background-color:#FFFFE0;padding: 20px">
<asp:Label ID="lblTime" runat="server" Font-
Bold="True"></asp:Label>
<br /><br />
<asp:Button ID="cmdRefreshTime" runat="server"
OnClick="cmdRefreshTime_Click"
Text="Start the Refresh Process" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<br />
<asp:UpdateProgress ID="updateProgress1" runat="server">
<ProgressTemplate>
<div style="font-size: xx-small">
Contacting Server ... <img src="wait.gif" alt="Waiting..." />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
In some situations, you might want to force a full or
partial page refresh without waiting for a user
action.

For example, you might create a page that includes
a stock ticker, and you might want to refresh this
ticker periodically (say, every five minutes) to
ensure it doesn’t become drastically outdated.

ASP.NET includes a Timer control that allows you to
implement this design easily.
<asp:Timer ID="Timer1" runat="server"
Interval="60000" />

<asp:UpdatePanel ID="UpdatePanel1"
runat="server" UpdateMode="Conditional">
<ContentTemplate>
...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger
ControlID="Timer1" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
The ASP.NET AJAX Control Toolkit is a joint project
between Microsoft and the ASP.NET community. It
consists of dozens of controls that use the ASP.NET
AJAX libraries to create sophisticated effects.

To get the ASP.NET AJAX Control Toolkit, surf to
http://www.asp.net/ajaxlibrary/act.ashx.

A 6.4 MB ZIP file which is designed for ASP.NET 4 is
named AjaxControlToolkit.Binary.NET4.zip.

Inside the ZIP file, you’ll find a central assembly named
AjaxControlToolkit.dll and a host of smaller satellite
assemblies that support localization for different
cultures.

More Related Content

PPTX
ASP.NET Page Life Cycle
PPTX
Mule tcat server - common problems and solutions
PPTX
Asp.net event handler
PPTX
Integrate with facebook connector
PPTX
Integration with dropbox
PPTX
Page life cycle IN ASP.NET
PPTX
Anypoint lessons
PPT
Asp.net tips
ASP.NET Page Life Cycle
Mule tcat server - common problems and solutions
Asp.net event handler
Integrate with facebook connector
Integration with dropbox
Page life cycle IN ASP.NET
Anypoint lessons
Asp.net tips

What's hot (20)

PPTX
Deploy with maven
PDF
Wap tquickstart
PPTX
Demo on Mule ESB Facebook Connector
PPT
ASP.NET Session 9
PPTX
PPTX
Cloud hub with mule
PPTX
Expose web service
PPSX
03 asp.net session04
ODP
Example mule
PDF
App engine install-windows
PPTX
Asp.net life cycle in depth
PPTX
My journey and learnings using mule esb part 1
PPTX
Java spring mysql without hibernate(2) (1)
PPTX
Integrate to retrieve data microsoft azure
PPT
ASP.NET Session 10
PPTX
Configuring Anypoint Studio MQ connector
PPTX
Web Controls Set-1
PPTX
Mule esb - How to connect to a MySql Database in 5 minutes
PPTX
Mule maven
PPT
ASP.NET Session 6
Deploy with maven
Wap tquickstart
Demo on Mule ESB Facebook Connector
ASP.NET Session 9
Cloud hub with mule
Expose web service
03 asp.net session04
Example mule
App engine install-windows
Asp.net life cycle in depth
My journey and learnings using mule esb part 1
Java spring mysql without hibernate(2) (1)
Integrate to retrieve data microsoft azure
ASP.NET Session 10
Configuring Anypoint Studio MQ connector
Web Controls Set-1
Mule esb - How to connect to a MySql Database in 5 minutes
Mule maven
ASP.NET Session 6
Ad

Viewers also liked (20)

PPTX
Intro To ECAT
PPTX
PPTX
PPTX
PPTX
CSS3 notes
PPTX
HTML5 &CSS: Chapter 08
PPTX
HTML: Chapter 01
PPTX
HTML & CSS: Chapter 07
PPTX
Html and CSS: Chapter 02
PPTX
HTML & CSS: Chapter 03
PPTX
HTML & CSS: Chapter 06
PPT
CSS - Basics
PPTX
Unit 6, Lesson 3 - Vectors
PPTX
HTML & CSS: Chapter 04
PDF
Bread board
PPT
Breadboard
PPT
Basic css
PPTX
Web Engineering - Basic CSS Properties
PPTX
Vernier caliper
PPT
Spline Interpolation
Intro To ECAT
CSS3 notes
HTML5 &CSS: Chapter 08
HTML: Chapter 01
HTML & CSS: Chapter 07
Html and CSS: Chapter 02
HTML & CSS: Chapter 03
HTML & CSS: Chapter 06
CSS - Basics
Unit 6, Lesson 3 - Vectors
HTML & CSS: Chapter 04
Bread board
Breadboard
Basic css
Web Engineering - Basic CSS Properties
Vernier caliper
Spline Interpolation
Ad

Similar to Chapter 25 (20)

PPTX
PPT
SynapseIndia dotnet development panel control
PPTX
Ajax and ASP.NET AJAX
PPTX
Ajax control asp.net
PPT
ASP.NET AJAX Basics
PPTX
Web forms in ASP.net
PDF
C sharp and asp.net interview questions
PPTX
Chanhao Jiang And David Wei Presentation Quickling Pagecache
PPTX
NET_Training.pptx
PPT
ASP.NET 04 - Additional Web Server Controls
PPTX
Accessibility with Single Page Apps
PPT
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
PPT
Asp.net control
PPTX
ASP.net.pptx
PPS
03 asp.net session04
DOCX
High performance coding practices code project
DOC
Abap objects in action
ZIP
ASP.Net Presentation Part1
PPT
SynapseIndia asp.net2.0 ajax Development
PPSX
13 asp.net session19
SynapseIndia dotnet development panel control
Ajax and ASP.NET AJAX
Ajax control asp.net
ASP.NET AJAX Basics
Web forms in ASP.net
C sharp and asp.net interview questions
Chanhao Jiang And David Wei Presentation Quickling Pagecache
NET_Training.pptx
ASP.NET 04 - Additional Web Server Controls
Accessibility with Single Page Apps
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
Asp.net control
ASP.net.pptx
03 asp.net session04
High performance coding practices code project
Abap objects in action
ASP.Net Presentation Part1
SynapseIndia asp.net2.0 ajax Development
13 asp.net session19

More from application developer (20)

PPTX
PPTX
DOCX
DOCX
Next step job board (Assignment)
PPTX
PPTX
PPTX
DOCX
Week 3 assignment
PPTX
PPTX
PPTX
PPTX
PPTX
DOCX
C # test paper
PPTX
PPTX
Chapter 8 part2
PPTX
Chapter 8 part1
PPTX
PPTX
PPTX

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPT
Teaching material agriculture food technology
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Teaching material agriculture food technology
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
MYSQL Presentation for SQL database connectivity
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
20250228 LYD VKU AI Blended-Learning.pptx
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Network Security Unit 5.pdf for BCA BBA.
Reach Out and Touch Someone: Haptics and Empathic Computing
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
Chapter 3 Spatial Domain Image Processing.pdf

Chapter 25

  • 1. • Understanding Ajax • Advantages & Disadvantages of Ajax • The Script Manager • Update Panel • Partial Updates • Conditional Updates • Triggers • Progress Notification • Timed Refreshes • ASP.NET AJAX Control Toolkit
  • 2. Ajax is programming shorthand for a set of techniques that create more responsive, dynamic pages that refresh themselves quickly and flicker-free. One of the hallmarks of Ajax is the ability to refresh part of the page while leaving the rest untouched. Technically, it’s a short form for Asynchronous JavaScript and XML, although this technique is now considered to be just one of several possible characteristics of an Ajax web application.
  • 3. • The key benefit of Ajax is responsiveness because it can react immediately updating the page partially, leaving the unchanged portion untouched • An Ajax application, when done properly, provides a better flicker free experience for the user. • Complexity • Browser Support
  • 4. In order to use ASP.NET AJAX, you need to place the ScriptManager control on your webpage. It adds the links to the ASP.NET AJAX JavaScript libraries. It does that by inserting a script block <script src="/YourWebSite/ScriptResource.axd?d=RUSU1mI ..." type="text/javascript"> </script> ScriptResource.axd is a resource that tells ASP.NET to find a JavaScript file that’s embedded in one of the compiled .NET 4 assemblies. The JavaScript file is only downloaded once, and then cached by the browser so it can be used by various pages in the website.
  • 5. ASP.NET includes a handy control called UpdatePanel that lets you take an ordinary page with server-side logic and make sure it refreshes itself in flicker-free Ajax style using partial updates. The basic idea is that you divide your web page into one or more distinct regions, each of which is wrapped inside an invisible UpdatePanel. When an event occurs in a control that’s located inside an UpdatePanel, and this event would normally trigger a full-page postback, the UpdatePanel intercepts the event and performs an asynchronous callback instead. The only difference is the means of communication (the page uses an asynchronous call to get the new data) and the way the received data is dealt with (the UpdatePanel refreshes its inner content, but the remainder of the page is not changed).
  • 6. 1. The user clicks a button inside an UpdatePanel. 2. The UpdatePanel intercepts the client-side click. Now, ASP.NET AJAX performs a callback to the server instead of a full-page postback. 3. On the server, normal page life cycle executes, with all the usual events. Finally, the page is rendered to HTML and returned to the browser. 4. ASP.NET AJAX receives HTML content for every UpdatePanel on the page. The client-side script code then updates the page, replacing the existing HTML that’s in each panel with the new content. (If a change has occurred to content that’s not inside an UpdatePanel, it’s ignored.)
  • 7. The key technique in an Ajax web application is partial refreshes. With partial refreshes, the entire page doesn’t need to be posted back and refreshed in the browser. The request takes place in the background, so the webpage remains responsive. When the web page receives the response, it updates just the changed portion of the page,
  • 9. In complex pages, you might have more than one UpdatePanel. In this case, when one UpdatePanel triggers an update, all the UpdatePanel regions will be refreshed. In this situation, you can configure the panels to update themselves independently. Simply change the UpdatePanel.UpdateMode property from Always to Conditional. The UpdatePanel will refresh itself only if an event occurs in one of the controls in that UpdatePanel.
  • 10. If you move the controls that fire postback out of the UpdatePanel, their events won’t be intercepted any longer, and they’ll trigger full-page postbacks with the familiar flicker. The solution is to explicitly tell the UpdatePanel to monitor those controls, even though they aren’t inside the UpdatePanel. You can do this by adding triggers to the UpdatePanel. Just select the UpdatePanel, click the Triggers property in the Properties window, and click the ellipsis (...) that appears in the Triggers box. Visual Studio will open a dialog box where you can add as many triggers as you want, and pick the control for each trigger from a drop- down list.
  • 11. <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Font- Bold="True"></asp:Label> <br /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID=“cmdPostBack" /> </Triggers> </asp:UpdatePanel> <asp:Button ID="cmdPostback" runat="server" Text="Refresh Full Page" />
  • 12. ASP.NET includes UpdateProgress control that allows you to show a message while a time-consuming asynchronous request is under way. The UpdateProgress control works in conjunction with the UpdatePanel. When you add the UpdateProgress control to a page, you get the ability to specify some content that will appear as soon as an asynchronous request is started and disappear as soon as the request is finished. This content can include a fixed message, but many people prefer to use an animated GIF
  • 13. <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div style="background-color:#FFFFE0;padding: 20px"> <asp:Label ID="lblTime" runat="server" Font- Bold="True"></asp:Label> <br /><br /> <asp:Button ID="cmdRefreshTime" runat="server" OnClick="cmdRefreshTime_Click" Text="Start the Refresh Process" /> </div> </ContentTemplate> </asp:UpdatePanel> <br /> <asp:UpdateProgress ID="updateProgress1" runat="server"> <ProgressTemplate> <div style="font-size: xx-small"> Contacting Server ... <img src="wait.gif" alt="Waiting..." /> </div> </ProgressTemplate> </asp:UpdateProgress>
  • 14. In some situations, you might want to force a full or partial page refresh without waiting for a user action. For example, you might create a page that includes a stock ticker, and you might want to refresh this ticker periodically (say, every five minutes) to ensure it doesn’t become drastically outdated. ASP.NET includes a Timer control that allows you to implement this design easily.
  • 15. <asp:Timer ID="Timer1" runat="server" Interval="60000" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> ... </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> </asp:UpdatePanel>
  • 16. The ASP.NET AJAX Control Toolkit is a joint project between Microsoft and the ASP.NET community. It consists of dozens of controls that use the ASP.NET AJAX libraries to create sophisticated effects. To get the ASP.NET AJAX Control Toolkit, surf to http://www.asp.net/ajaxlibrary/act.ashx. A 6.4 MB ZIP file which is designed for ASP.NET 4 is named AjaxControlToolkit.Binary.NET4.zip. Inside the ZIP file, you’ll find a central assembly named AjaxControlToolkit.dll and a host of smaller satellite assemblies that support localization for different cultures.