SlideShare uma empresa Scribd logo
1 de 16
• 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,
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.

Mais conteúdo relacionado

Mais procurados

ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
Sisir Ghosh
 
Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)
AmedJacobReza
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
Sisir Ghosh
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
Sisir Ghosh
 

Mais procurados (20)

Deploy with maven
Deploy with mavenDeploy with maven
Deploy with maven
 
Wap tquickstart
Wap tquickstartWap tquickstart
Wap tquickstart
 
Demo on Mule ESB Facebook Connector
Demo on Mule ESB Facebook ConnectorDemo on Mule ESB Facebook Connector
Demo on Mule ESB Facebook Connector
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
Mule esb
Mule esbMule esb
Mule esb
 
Cloud hub with mule
Cloud hub with muleCloud hub with mule
Cloud hub with mule
 
Expose web service
Expose web serviceExpose web service
Expose web service
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
Example mule
Example muleExample mule
Example mule
 
App engine install-windows
App engine install-windowsApp engine install-windows
App engine install-windows
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depth
 
My journey and learnings using mule esb part 1
My journey and learnings using mule esb part 1My journey and learnings using mule esb part 1
My journey and learnings using mule esb part 1
 
Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)Java spring mysql without hibernate(2) (1)
Java spring mysql without hibernate(2) (1)
 
Integrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azureIntegrate to retrieve data microsoft azure
Integrate to retrieve data microsoft azure
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
Configuring Anypoint Studio MQ connector
Configuring Anypoint Studio MQ connectorConfiguring Anypoint Studio MQ connector
Configuring Anypoint Studio MQ connector
 
Web Controls Set-1
Web Controls Set-1Web Controls Set-1
Web Controls Set-1
 
Mule esb - How to connect to a MySql Database in 5 minutes
Mule esb - How to connect to a MySql Database in 5 minutesMule esb - How to connect to a MySql Database in 5 minutes
Mule esb - How to connect to a MySql Database in 5 minutes
 
Mule maven
Mule mavenMule maven
Mule maven
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
 

Destaque

Destaque (20)

Intro To ECAT
Intro To ECATIntro To ECAT
Intro To ECAT
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
CSS
CSSCSS
CSS
 
Chapter 19
Chapter 19Chapter 19
Chapter 19
 
CSS3 notes
CSS3 notesCSS3 notes
CSS3 notes
 
HTML5 &CSS: Chapter 08
HTML5 &CSS: Chapter 08HTML5 &CSS: Chapter 08
HTML5 &CSS: Chapter 08
 
HTML: Chapter 01
HTML: Chapter 01HTML: Chapter 01
HTML: Chapter 01
 
HTML & CSS: Chapter 07
HTML & CSS: Chapter 07HTML & CSS: Chapter 07
HTML & CSS: Chapter 07
 
Html and CSS: Chapter 02
Html and CSS: Chapter 02Html and CSS: Chapter 02
Html and CSS: Chapter 02
 
HTML & CSS: Chapter 03
HTML & CSS: Chapter 03HTML & CSS: Chapter 03
HTML & CSS: Chapter 03
 
HTML & CSS: Chapter 06
HTML & CSS: Chapter 06HTML & CSS: Chapter 06
HTML & CSS: Chapter 06
 
CSS - Basics
CSS - BasicsCSS - Basics
CSS - Basics
 
Unit 6, Lesson 3 - Vectors
Unit 6, Lesson 3 - VectorsUnit 6, Lesson 3 - Vectors
Unit 6, Lesson 3 - Vectors
 
HTML & CSS: Chapter 04
HTML & CSS: Chapter 04HTML & CSS: Chapter 04
HTML & CSS: Chapter 04
 
Bread board
Bread boardBread board
Bread board
 
Breadboard
BreadboardBreadboard
Breadboard
 
Basic css
Basic cssBasic css
Basic css
 
Web Engineering - Basic CSS Properties
Web Engineering - Basic CSS PropertiesWeb Engineering - Basic CSS Properties
Web Engineering - Basic CSS Properties
 
Vernier caliper
Vernier caliperVernier caliper
Vernier caliper
 
Spline Interpolation
Spline InterpolationSpline Interpolation
Spline Interpolation
 

Semelhante a Chapter 25

ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basics
petrov
 
Chanhao Jiang And David Wei Presentation Quickling Pagecache
Chanhao Jiang And David Wei Presentation Quickling PagecacheChanhao Jiang And David Wei Presentation Quickling Pagecache
Chanhao Jiang And David Wei Presentation Quickling Pagecache
Ajax Experience 2009
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Mani Chaubey
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code project
Pruthvi B Patil
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
Neeraj Mathur
 
Ajax And Your Cms
Ajax And Your CmsAjax And Your Cms
Ajax And Your Cms
yiditushe
 

Semelhante a Chapter 25 (20)

Ajax
AjaxAjax
Ajax
 
SynapseIndia dotnet development panel control
SynapseIndia dotnet development panel controlSynapseIndia dotnet development panel control
SynapseIndia dotnet development panel control
 
Ajax and ASP.NET AJAX
Ajax and ASP.NET AJAXAjax and ASP.NET AJAX
Ajax and ASP.NET AJAX
 
Ajax control asp.net
Ajax control asp.netAjax control asp.net
Ajax control asp.net
 
ASP.NET AJAX Basics
ASP.NET AJAX BasicsASP.NET AJAX Basics
ASP.NET AJAX Basics
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
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
 
Chanhao Jiang And David Wei Presentation Quickling Pagecache
Chanhao Jiang And David Wei Presentation Quickling PagecacheChanhao Jiang And David Wei Presentation Quickling Pagecache
Chanhao Jiang And David Wei Presentation Quickling Pagecache
 
NET_Training.pptx
NET_Training.pptxNET_Training.pptx
NET_Training.pptx
 
ASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server ControlsASP.NET 04 - Additional Web Server Controls
ASP.NET 04 - Additional Web Server Controls
 
Accessibility with Single Page Apps
Accessibility with Single Page AppsAccessibility with Single Page Apps
Accessibility with Single Page Apps
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
ASP.net.pptx
ASP.net.pptxASP.net.pptx
ASP.net.pptx
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code project
 
Abap objects in action
Abap objects in actionAbap objects in action
Abap objects in action
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
SynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax DevelopmentSynapseIndia asp.net2.0 ajax Development
SynapseIndia asp.net2.0 ajax Development
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
Ajax And Your Cms
Ajax And Your CmsAjax And Your Cms
Ajax And Your Cms
 

Mais de application developer (20)

Chapter 26
Chapter 26Chapter 26
Chapter 26
 
Chapter 23
Chapter 23Chapter 23
Chapter 23
 
Assignment
AssignmentAssignment
Assignment
 
Next step job board (Assignment)
Next step job board (Assignment)Next step job board (Assignment)
Next step job board (Assignment)
 
Chapter 18
Chapter 18Chapter 18
Chapter 18
 
Chapter 17
Chapter 17Chapter 17
Chapter 17
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
Week 3 assignment
Week 3 assignmentWeek 3 assignment
Week 3 assignment
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Chapter 14
Chapter 14Chapter 14
Chapter 14
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
C # test paper
C # test paperC # test paper
C # test paper
 
Chapter 9
Chapter 9Chapter 9
Chapter 9
 
Chapter 8 part2
Chapter 8   part2Chapter 8   part2
Chapter 8 part2
 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
 
Chapter 7
Chapter 7Chapter 7
Chapter 7
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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,
  • 8.
  • 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.