Beantown Ajax
Beantown Ajax
NET AJAX
Eric Tobia 12/7/2006 Beantown .NET UG
Outline
Defining AJAX ASP.NET AJAX Including ASP.NET AJAX Script Manager Update Panel Client Networking - Web/Script Services Extender Controls - Control Toolkit Client Side JavaScript Development
AJAX Sites
GMail http://mail.google.com Google Maps http://maps.google.com Outlook Web Access PageFlakes - http://www.pageflakes.com/ Smart Scoreboard - http://www.smartscoreboard.com/
Acronym
Asynchronous JavaScript And XML
Web Server
AJAX Application
Initial Web Page Request (WebPage.aspx)
Async Requests
Client side script updates the content of the page using the data returned from the async requests
Web Server
Potential Benefits
continuous feedback Update only a portion of the page Users dont have to:
Wait for the entire page to refresh Re-orient themselves after a page refresh
pushing data to the browser Example: A list of stock prices that update without refreshing the whole page
Challenges
Users will start to expect AJAX features Most ASP.NET devs are used to a server side programming model
Sophisticated
Browser incompatibilities
Potential Solution
AJAX Frameworks/Libraries
Make
AJAX Frameworks* 16 for .NET* Well go with ASP.NET AJAX for this talk
*Source: http://www.ajaxpatterns.org
Server Side
Uses
server controls to enable AJAX Very little (if any) JavaScript coding required
Client Side
Sys.* namespaces
Heavy
Disclaimer
Beta Software There are still some issues Use with caution
Script Manager
Heart of ASP.NET AJAX Required for using ASP.NET AJAX Registers AJAX Client Library Enables partial page rendering (Update Panels) Can be used for registering custom scripts Script Reference JS Proxy Classes For Web Services Service Reference
Update Panel
Update regions of the web page Quickest path to AJAX enabling an ASP.NET site Async Postback/Partial Rendering Post back interception
Update Panel
Update Mode
Always Conditional
Triggers
Children External
Demos
Enhance Existing Pages Update Progress Bar Timer Control
The ScriptManagers PageRequestManager steps in during PreRender() and replaces the Pages Render() method with one that renders Update Panel content.
Web/Script Services
Access web services from client side JavaScript Serialize custom classes to JSON
JavaScript
Object Notation
JSON
{"breakfast-menu": { "food":[ {"name": "Belgian Waffles", "price": "5.95", "description": "two of our famous Belgian Waffles with ...", "calories": "650" }, {"name": "Strawberry Belgian Waffles", "price": "7.95", "description": "light Belgian waffles covered with ...", "calories": "900" } ] }
Source: http://www.softwaresecretweapons.com/jspwiki/Wiki.jsp?page=AJAXWithoutXML
JSON
{
"type": "menu", "value": "File", "items": [ {"value": "New", "action": "CreateNewDoc"}, {"value": "Open", "action": "OpenDoc"}, {"value": "Close", "action": "CloseDoc"} ] }
Source: http://en.wikipedia.org/wiki/JSON
Demos
Async web service using JSON AutoCompleteExtender
Extender Controls
ASP.NET server controls Target an existing web control
TargetControlId
Control
http://www.codeplex.com
Demos
Control Toolkit Samples Filtered Text Box/Watermark
ASP.NET AJAX Client Library Dudewheres my intellisense for JS? Orcas Dudewheres my designer support for xml-script? Orcas
XML Script
This XML-Script would be part of a larger ASPX page
<script type="text/xml-script"> <page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <components> <label id="MyLabel" /> <button id="MyFirstButton"> <click> <setProperty target="MyLabel" property="cssClass" value=lameStyle"/> </click> </button> <button id="MySecondButton"> <click> <setProperty target="MyLabel" property="cssClass" value=coolStyle"/> </click> </button> </components> </page> </script> MyLabel, MyFirstButton, and [ASPX PAGE]
MySecondButton are elements on the page. lameStyle and coolStyle are CSS classes.
ASP.NET AJAX
Atlas ..and then there were 3
ASP.NET
ASP.NET
ASP.NET
Server
ScriptManager UpdatePanel
JSON
Client
Type
Server
AutoCompleteExtender DragOverlayExtender
Client
Sys.Preview.UI.* xml-script Client
Thanks!