SlideShare a Scribd company logo
AJAX in ASP.NET
James Crowley
Developer Fusion
http://www.developerfusion.co.uk/
Overview
 What is AJAX?
 How does it work?
 Using it in ASP.NET 1.x
 Using it in ASP.NET 2.0
 Pros & Cons
What is AJAX (and who cares?)
 Current postback solutions can be slow
and confusing to users
 AJAX allows server-side processing to
occur without a postback, and therefore...
a more interactive & responsive UI
 Nothing new, but all the rage thanks to
Google Maps, Flickr, and A9 to name a
few
How it works
Server
Web Server
Database
Client Browser
JavaScript
DHTML
XML HTTP
Object
1
Async HTTP Request
How it works
Server
Web Server
Database
Client Browser
JavaScript
DHTML
XML HTTP
Object
2
How it works
Server
Web Server
Database
Client Browser
JavaScript
DHTML
XML HTTP
Object
3
Async HTTP Response
AJAX in ASP.NET 1.x
 Either we deal with the XML HTTP
request ourselves
 or we can use an existing library, such as
AJAX.NET wrapper
http://ajax.schwarz-interactive.de/
“My AJAX.NET”
http://jason.diamond.name/weblog/
Demo
 “Colourizing” Code
Complex Data Types
 Need to either reproduce (a subset of) the
.NET type system within JavaScript or
vice-versa
 Need to serialize for transfer via HTTP
 Serializable return types dealt with
automatically
 Parameters are harder
Demo
 “Google Suggest”
AJAX in ASP.NET 2.0
 Known as “Script Callbacks”
 Call ClientScript.GetCallBackEventReference to
get the string for a javascript call to trigger a
callback
 Implement the ICallbackEventHandler interface
public interface ICallbackEventHandler {
void RaiseCallbackEvent(string eventArgument);
String GetCallbackResult();
}
public string GetCallbackEventReference(System.Web.UI.Control control,
string argument, string clientCallback,
string context, string clientErrorCallback, bool useAsync)
ASP.NET 2.0 vs AJAX.NET
 No dynamic mapping of parameters using
reflection
 More complicated with multiple callbacks
 No JavaScript objects corresponding to
server-side types (only returning strings)
 Executes within the page lifecycle
Things to note
 ViewState not updated during a callback
because of allowance for parallel callbacks
 Page.IsPostBack is true for callbacks and
postbacks. Use Page.IsCallback
 Request.Browser.SupportsCallback
Demo
 AJAX in ASP.NET 2.0
Atlas
 New library from Microsoft to plug-in to
ASP.NET 2.0
 Preview available from http://atlas.asp.net/
 Warning: Not yet even Beta quality!
 But Microsoft wants your feedback…
Atlas
 Cross-browser script libraries
 Callbacks can be triggered in same way as
AJAX.NET library
 Web Services integration
 Declarative data binding
 New AJAX-enabled server controls
Things to watch out for…
 Debugging is a pain
 Response timeouts and server exceptions
 Non-JavaScript/non-ActiveX scenarios
Things to watch out for…
 Accessibility, page flow, scroll position
 Can break layered architectures
 Inability to access by URL, and breaking
back/forward browser buttons
 No search indexing for AJAX’ed data
Wrapping Up
 More work for us
 But… fast interactive UI for the user
 Any questions?
References
 ASP.NET AJAX Libraries
 http://ajax.schwarz-interactive.de/ (AJAX.NET)
 Tutorial @ http://www.developerfusion.co.uk/show/4704/
 http://jason.diamond.name/weblog/ (My AJAX.NET)
 http://atlas.asp.net/ (Atlas)
 My Contact Details
 Web: http://www.developerfusion.co.uk/
 Email: james@developerfusion.co.uk

More Related Content

PPT
Introduction to ajax
PPT
Advantages and disadvantages of an ajax based client application
PPTX
Overview of AJAX
PPTX
Introduction to ajax
PPT
Ajax & ASP.NET 2
PPT
Ajax Presentation
Introduction to ajax
Advantages and disadvantages of an ajax based client application
Overview of AJAX
Introduction to ajax
Ajax & ASP.NET 2
Ajax Presentation

What's hot (20)

PPT
Ajax Ppt 1
PPT
DOCX
Jquery Ajax
PPT
Asynchronous JavaScript & XML (AJAX)
PPT
Introduction To Asp.Net Ajax
PPTX
Ajax technology
PDF
Ajax basics
PPTX
Ajax and ASP.NET AJAX
PDF
Introduction to ajax
PPTX
Architecture in Ajax Applications
PPT
Ajax workshop
PPTX
ASP .NET MVC - best practices
PDF
Ajax Introduction Presentation
PPT
PPT
Using Ajax In Domino Web Applications
PPTX
Ajax ppt - 32 slides
PPTX
Architecting ASP.NET MVC Applications
PPTX
Ajax PPT
Ajax Ppt 1
Jquery Ajax
Asynchronous JavaScript & XML (AJAX)
Introduction To Asp.Net Ajax
Ajax technology
Ajax basics
Ajax and ASP.NET AJAX
Introduction to ajax
Architecture in Ajax Applications
Ajax workshop
ASP .NET MVC - best practices
Ajax Introduction Presentation
Using Ajax In Domino Web Applications
Ajax ppt - 32 slides
Architecting ASP.NET MVC Applications
Ajax PPT
Ad

Similar to AJAX in ASP.NET (20)

PPTX
New microsoft office power point presentation
PPT
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
PPT
ASP.NET AJAX with Visual Studio 2008
PPT
ASP.NET 4.0 Roadmap
PPT
Ajax: User Experience
TXT
25250716 seminar-on-ajax text
PPTX
Walther Ajax4
PPT
Ajax and PHP
PPTX
Usability AJAX and other ASP.NET Features
PPT
PPT
SynapseIndia asp.net2.0 ajax Development
PDF
Introduction to Asp.net 3.5 using VS 2008
PDF
Integrating ASP.NET AJAX with SharePoint
PPT
SynapseIndia dotnet development ajax client library
PDF
Ajax & Reverse Ajax Presenation
PPT
Ajax Frameworks in the J(2)EE Environment
PDF
M6 l8-ajax-handout
PPT
PPT
Ajax Presentation
ODP
New microsoft office power point presentation
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
ASP.NET AJAX with Visual Studio 2008
ASP.NET 4.0 Roadmap
Ajax: User Experience
25250716 seminar-on-ajax text
Walther Ajax4
Ajax and PHP
Usability AJAX and other ASP.NET Features
SynapseIndia asp.net2.0 ajax Development
Introduction to Asp.net 3.5 using VS 2008
Integrating ASP.NET AJAX with SharePoint
SynapseIndia dotnet development ajax client library
Ajax & Reverse Ajax Presenation
Ajax Frameworks in the J(2)EE Environment
M6 l8-ajax-handout
Ajax Presentation
Ad

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
cuic standard and advanced reporting.pdf
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
Per capita expenditure prediction using model stacking based on satellite ima...

AJAX in ASP.NET

  • 1. AJAX in ASP.NET James Crowley Developer Fusion http://www.developerfusion.co.uk/
  • 2. Overview  What is AJAX?  How does it work?  Using it in ASP.NET 1.x  Using it in ASP.NET 2.0  Pros & Cons
  • 3. What is AJAX (and who cares?)  Current postback solutions can be slow and confusing to users  AJAX allows server-side processing to occur without a postback, and therefore... a more interactive & responsive UI  Nothing new, but all the rage thanks to Google Maps, Flickr, and A9 to name a few
  • 4. How it works Server Web Server Database Client Browser JavaScript DHTML XML HTTP Object 1 Async HTTP Request
  • 5. How it works Server Web Server Database Client Browser JavaScript DHTML XML HTTP Object 2
  • 6. How it works Server Web Server Database Client Browser JavaScript DHTML XML HTTP Object 3 Async HTTP Response
  • 7. AJAX in ASP.NET 1.x  Either we deal with the XML HTTP request ourselves  or we can use an existing library, such as AJAX.NET wrapper http://ajax.schwarz-interactive.de/ “My AJAX.NET” http://jason.diamond.name/weblog/
  • 9. Complex Data Types  Need to either reproduce (a subset of) the .NET type system within JavaScript or vice-versa  Need to serialize for transfer via HTTP  Serializable return types dealt with automatically  Parameters are harder
  • 11. AJAX in ASP.NET 2.0  Known as “Script Callbacks”  Call ClientScript.GetCallBackEventReference to get the string for a javascript call to trigger a callback  Implement the ICallbackEventHandler interface public interface ICallbackEventHandler { void RaiseCallbackEvent(string eventArgument); String GetCallbackResult(); } public string GetCallbackEventReference(System.Web.UI.Control control, string argument, string clientCallback, string context, string clientErrorCallback, bool useAsync)
  • 12. ASP.NET 2.0 vs AJAX.NET  No dynamic mapping of parameters using reflection  More complicated with multiple callbacks  No JavaScript objects corresponding to server-side types (only returning strings)  Executes within the page lifecycle
  • 13. Things to note  ViewState not updated during a callback because of allowance for parallel callbacks  Page.IsPostBack is true for callbacks and postbacks. Use Page.IsCallback  Request.Browser.SupportsCallback
  • 14. Demo  AJAX in ASP.NET 2.0
  • 15. Atlas  New library from Microsoft to plug-in to ASP.NET 2.0  Preview available from http://atlas.asp.net/  Warning: Not yet even Beta quality!  But Microsoft wants your feedback…
  • 16. Atlas  Cross-browser script libraries  Callbacks can be triggered in same way as AJAX.NET library  Web Services integration  Declarative data binding  New AJAX-enabled server controls
  • 17. Things to watch out for…  Debugging is a pain  Response timeouts and server exceptions  Non-JavaScript/non-ActiveX scenarios
  • 18. Things to watch out for…  Accessibility, page flow, scroll position  Can break layered architectures  Inability to access by URL, and breaking back/forward browser buttons  No search indexing for AJAX’ed data
  • 19. Wrapping Up  More work for us  But… fast interactive UI for the user  Any questions?
  • 20. References  ASP.NET AJAX Libraries  http://ajax.schwarz-interactive.de/ (AJAX.NET)  Tutorial @ http://www.developerfusion.co.uk/show/4704/  http://jason.diamond.name/weblog/ (My AJAX.NET)  http://atlas.asp.net/ (Atlas)  My Contact Details  Web: http://www.developerfusion.co.uk/  Email: james@developerfusion.co.uk