SlideShare a Scribd company logo
The ASP.NET AJAX Extensions Robert A Dennyson
Architecture ASP.NET 2.0 Page Framework & Server Controls Application Services ASP.NET AJAX Extensions Server Controls ASPX ASMX Application Services Bridge Asynchronous Communications
Server Controls UpdatePanel Update- Progress Timer DragOverlay- Extender ScriptManager ScriptManager- Proxy ProfileService Script Management Partial-Page Rendering Futures CTP
ScriptManager ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ScriptManager Schema <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot; EnablePartialRendering=&quot;true|false&quot; EnablePageMethods=&quot;true|false&quot; AsyncPostBackTimeout=&quot; seconds &quot; AsyncPostBackErrorMessage=&quot; message &quot; AllowCustomErrorsRedirect=&quot;true|false&quot; OnAsyncPostBackError=&quot; handler &quot; EnableScriptGlobalization=&quot;true|false&quot; EnableScriptLocalization=&quot;true|false&quot; ScriptMode=&quot;Auto|Inherit|Debug|Release&quot; ScriptPath=&quot; path &quot;> <Scripts> <!-- Declare script references here --> </Scripts> <Services> <!-- Declare Web service references here --> </Services> </asp:ScriptManager>
Script References <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Scripts> <asp:ScriptReference Name=&quot;PreviewScript.js&quot; Assembly=&quot;Microsoft.Web.Preview&quot; /> <asp:ScriptReference Name=&quot;PreviewDragDrop.js&quot; Assembly=&quot;Microsoft.Web.Preview&quot; /> <asp:ScriptReference Path=&quot;~/Scripts/UIMap.js&quot; /> </Scripts> </asp:ScriptManager> &quot;Path&quot; references load script files &quot;Name&quot; references load script resources
Service References <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Services> <asp:ServiceReference Path=&quot;ZipCodeService.asmx&quot; /> </Services> </asp:ScriptManager>
ScriptManagerProxy ,[object Object],[object Object],<asp:ScriptManagerProxy ID=&quot;ScriptManagerProxy1&quot; Runat=&quot;server&quot;> <Scripts> <!-- Declare additional script references here --> </Scripts> <Services> <!-- Declare additional service references here --> </Services> </asp:ScriptManagerProxy>
UpdatePanel ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
UpdatePanel Schema <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot; EnablePartialRendering=&quot;true&quot; /> . . . <asp:UpdatePanel ID=&quot;UpdatePanel1&quot; Runat=&quot;server&quot; UpdateMode=&quot;Always|Conditional&quot; ChildrenAsTriggers=&quot;true|false&quot;> <Triggers> <!-- Define triggers (if any) here --> </Triggers> <ContentTemplate> <!-- Define content here --> </ContentTemplate> </asp:UpdatePanel>
Triggers ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Triggers Example <asp:UpdatePanel ID=&quot;UpdatePanel1&quot; Runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;> <Triggers> <asp:AsyncPostBackTrigger ControlID=&quot;Button1&quot; /> <asp:AsyncPostBackTrigger ControlID=&quot;TreeView1&quot; EventName=&quot;TreeNodeExpanded&quot; /> <asp:AsyncPostBackTrigger ControlID=&quot;TreeView1&quot; EventName=&quot;TreeNodeCollapsed&quot; /> <asp:PostBackTrigger ControlID=&quot;Button2&quot; /> </Triggers> <ContentTemplate> ... </ContentTemplate> </asp:UpdatePanel>
Periodic Updates ,[object Object],[object Object],<asp:Timer ID=&quot;Timer1&quot; Runat=&quot;server&quot; Interval=&quot;5000&quot; OnTick=&quot;OnTimerTick&quot; /> ... <asp:UpdatePanel UpdateMode=&quot;Conditional&quot; ...> <Triggers> <asp:AsyncPostBackTrigger ControlID=&quot;Timer1&quot; /> </Triggers> ... </asp:UpdatePanel>
UpdatePanel
UpdateProgress ,[object Object],[object Object],[object Object],[object Object],[object Object]
UpdateProgress Schema <asp:UpdateProgress ID=&quot;UpdateProgress1&quot; Runat=&quot;server&quot; DisplayAfter=&quot; milliseconds &quot; DynamicLayout=&quot;true|false&quot; AssociatedUpdatePanelID=&quot; UpdatePanelID &quot;> <ProgressTemplate> <!-- Declare UpdateProgress UI here --> </ProgressTemplate> </asp:UpdateProgress>
UpdateProgress Example <asp:UpdateProgress DisplayAfter=&quot;500&quot; ...> <ProgressTemplate> <asp:Image ID=&quot;ProgressImage&quot; Runat=&quot;server&quot; ImageUrl=&quot;~/Images/SpinningClock.gif&quot; /> </ProgressTemplate> </asp:UpdateProgress> Animated GIF Display after ½ second
Canceling an Update <asp:UpdateProgress DisplayAfter=&quot;500&quot; ...> <ProgressTemplate> <b>Working...</b> <asp:Button ID=&quot;CancelButton&quot; Runat=&quot;server&quot; Text=&quot;Cancel&quot; OnClientClick=&quot;cancelUpdate(); return false&quot; /> </ProgressTemplate> </asp:UpdateProgress> <script type=&quot;text/javascript&quot;> function cancelUpdate() { var obj = Sys.WebForms.PageRequestManager.getInstance(); if (obj.get_isInAsyncPostBack()) obj.abortPostBack(); } </script>
UpdateProgress
ASP.NET AJAX Web Services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Script-Callable Web Service [System.Web.Script.Services.ScriptService] public class ZipCodeService : System.Web.Services.WebService { [System.Web.Services.WebMethod] public string[] GetCityAndState (string zip) { ... } }
Declaring a Service Reference <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Services> <asp:ServiceReference Path=&quot;ZipCodeService.asmx&quot; /> </Services> </asp:ScriptManager> <script src=&quot;ZipCodeService.asmx/js&quot; type=&quot;text/javascript&quot;> </script>
Consuming a Web Service ZipCodeService.GetCityAndState(&quot;98052&quot;, onCompleted); . . . function onCompleted (result) { window.alert(result); }
Handling Errors ZipCodeService.GetCityAndState(&quot;98052&quot;, onCompleted, onFailed); . . . function onCompleted (result, context, methodName) { window.alert(result); } function onFailed (err, context, methodName) { window.alert(err.get_message()); }
Web Services
ASMX Wire Format POST /AtlasRC/ZipCodeService.asmx/GetCityAndState HTTP/1.1 Accept: */* Accept-Language: en-us Referer: http://localhost:1997/AtlasRC/ZipCodePage.aspx UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; ...) Host: localhost:1997 Content-Length: 15 Connection: Keep-Alive Cache-Control: no-cache {&quot;zip&quot;:&quot;98052&quot;} Request HTTP/1.1 200 OK Server: ASP.NET Development Server/8.0.0.0 Date: Fri, 29 Dec 2006 21:06:17 GMT X-AspNet-Version: 2.0.50727 Cache-Control: private, max-age=0 Content-Type: application/json; charset=utf-8 Content-Length: 16 Connection: Close [&quot;REDMOND&quot;,&quot;WA&quot;] Response JSON-encoded input JSON-encoded output
ScriptHandlerFactory ,[object Object],[object Object],[object Object],[object Object],[object Object],<httpHandlers> <remove verb=&quot;*&quot; path=&quot;*.asmx&quot; /> <add verb=&quot;*&quot; path=&quot;*.asmx&quot; validate=&quot;false&quot; type=&quot;System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, ...&quot; /> </httpHandlers>
ASMX Request Handling ScriptHandler- Factory RestClient- ProxyHandler RestHandler WebService- HandlerFactory *.asmx &quot;Normal&quot; ASMX calls ASMX Extensions *.asmx/js *.asmx/ methodname Helper Classes Default ASMX handler
JSON ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JSON vs. XML Point p = new Point(100, 200); {&quot;IsEmpty&quot;:false,&quot;X&quot;:100,&quot;Y&quot;:200} JSON <?xml version=&quot;1.0&quot;?> <Point xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;> <X>100</X> <Y>200</Y> </Point> XML
The ScriptMethod Attribute ,[object Object],[object Object],Property Description UseHttpGet True = Use HTTP GET, False = Use HTTP POST (default) ResponseFormat ResponseFormat.Xml or ResponseFormat.Json (default) XmlSerializeString True = Serialize everything (including strings) as XML, False = Serialize response strings as JSON (default) (Only valid if ResponseFormat == ResponseFormat.Xml)
Using ScriptMethod [System.Web.Script.Services.ScriptService] public class ZipCodeService : System.Web.Services.WebService { [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod (ResponseFormat=ResponseFormat.Xml)] public XmlDocument GetCityAndState (string zip) { ... } } Method returns XML document, so serialize as XML rather than JSON
Page Methods ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Enabling Page Methods <asp:ScriptManager ID=&quot;ScriptManager1&quot; EnablePageMethods=&quot;true&quot; Runat=&quot;server&quot; /> var PageMethods = function() { PageMethods.initializeBase(this); this._timeout = 0; this._userContext = null; this._succeeded = null; this._failed = null; } PageMethods.prototype = { ... }
Defining a Page Method public partial class MyPage : System.Web.UI.Page { [System.Web.Services.WebMethod] public static string[] GetCityAndState (string zip) { ... } ... }
Calling a Page Method PageMethods.GetCityAndState(&quot;98052&quot;, onComplete); . . . function onComplete(result) { window.alert(result); }
Page Methods
Built-In Web Services ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using AuthenticationService Sys.Services.AuthenticationService.login (username, password, false, null, null, onLoginCompleted, onLoginFailed); ... function onLoginCompleted(result, context, methodName) { window.alert(result ? 'Login succeeded' : 'Login failed'); } function onLoginFailed(err, context, methodName) { window.alert(err.get_message()); }
Loading Profile Properties Sys.Services.ProfileService.load(['ScreenName'], onLoadCompleted, onLoadFailed); ... function onLoadCompleted(result, context, methodName) { window.alert(Sys.Services.ProfileService.properties.ScreenName); } function onLoadFailed(err, context, methodName) { window.alert(err.get_message()); } Pass null to load all profile properties
Saving Profile Properties Sys.Services.ProfileService.properties.ScreenName = 'Bob'; Sys.Services.ProfileService.save(['ScreenName'], onSaveCompleted, onSaveFailed); ... function onSaveCompleted(result, context, methodName) { window.alert('Save succeeded'); } function onSaveFailed(err, context, methodName) { window.alert(err.get_message()); } Pass null to save all profile properties
Discussion

More Related Content

Similar to AJAX ASP.Net

Aspnet2 Overview
Aspnet2 OverviewAspnet2 Overview
Aspnet2 Overviewajitbergi
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
ASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET WorksASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET Works
Randy Connolly
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Peter Gfader
 
Developing PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan FrameworkDeveloping PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan Framework
Raymond Irving
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
Maarten Balliauw
 
Web performance testing
Web performance testingWeb performance testing
Web performance testing
Patrick Meenan
 
Svcc2009 Async Ws
Svcc2009 Async WsSvcc2009 Async Ws
Svcc2009 Async Ws
Manoj Kumar
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
Andy Schwartz
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
SAMIR BHOGAYTA
 
WCF - In a Week
WCF - In a WeekWCF - In a Week
WCF - In a Week
gnanaarunganesh
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
Rob Windsor
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
yuvalb
 

Similar to AJAX ASP.Net (20)

ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
Controls
ControlsControls
Controls
 
Aspnet2 Overview
Aspnet2 OverviewAspnet2 Overview
Aspnet2 Overview
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
ASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET WorksASP.NET 02 - How ASP.NET Works
ASP.NET 02 - How ASP.NET Works
 
Vb.Net Web Forms
Vb.Net  Web FormsVb.Net  Web Forms
Vb.Net Web Forms
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Developing PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan FrameworkDeveloping PHP Web Applications with the Raxan Framework
Developing PHP Web Applications with the Raxan Framework
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
2310 b 04
2310 b 042310 b 04
2310 b 04
 
Web performance testing
Web performance testingWeb performance testing
Web performance testing
 
Svcc2009 Async Ws
Svcc2009 Async WsSvcc2009 Async Ws
Svcc2009 Async Ws
 
JSF Component Behaviors
JSF Component BehaviorsJSF Component Behaviors
JSF Component Behaviors
 
Ajax
AjaxAjax
Ajax
 
Intro To Asp Net And Web Forms
Intro To Asp Net And Web FormsIntro To Asp Net And Web Forms
Intro To Asp Net And Web Forms
 
WCF - In a Week
WCF - In a WeekWCF - In a Week
WCF - In a Week
 
Integrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePointIntegrating ASP.NET AJAX with SharePoint
Integrating ASP.NET AJAX with SharePoint
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Jsp Slides
Jsp SlidesJsp Slides
Jsp Slides
 
ASP.NET 4.0 Roadmap
ASP.NET 4.0 RoadmapASP.NET 4.0 Roadmap
ASP.NET 4.0 Roadmap
 

More from SHC

Perform brute force
Perform brute forcePerform brute force
Perform brute force
SHC
 
C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)
SHC
 
Inside Asp.Net Web Matrix
Inside Asp.Net Web MatrixInside Asp.Net Web Matrix
Inside Asp.Net Web MatrixSHC
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedSHC
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedSHC
 
V Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedV Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedSHC
 
Intel® V Pro™ Technology
Intel® V Pro™ TechnologyIntel® V Pro™ Technology
Intel® V Pro™ Technology
SHC
 
XForms with Linux
XForms with LinuxXForms with Linux
XForms with Linux
SHC
 
XForms
XFormsXForms
XFormsSHC
 
Rails
RailsRails
RailsSHC
 
Call
CallCall
CallSHC
 
Action Mailer
Action MailerAction Mailer
Action Mailer
SHC
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
SHC
 
Web Services
Web ServicesWeb Services
Web Services
SHC
 
Pragmatic Agile Web Development With Rails.3rd Edition.2009
Pragmatic   Agile Web Development With Rails.3rd Edition.2009Pragmatic   Agile Web Development With Rails.3rd Edition.2009
Pragmatic Agile Web Development With Rails.3rd Edition.2009
SHC
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
SHC
 
Ruby Installation
Ruby InstallationRuby Installation
Ruby Installation
SHC
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
SHC
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
SHC
 
Mysql
MysqlMysql
Mysql
SHC
 

More from SHC (20)

Perform brute force
Perform brute forcePerform brute force
Perform brute force
 
C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)C++ plus data structures, 3rd edition (2003)
C++ plus data structures, 3rd edition (2003)
 
Inside Asp.Net Web Matrix
Inside Asp.Net Web MatrixInside Asp.Net Web Matrix
Inside Asp.Net Web Matrix
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii Edited
 
V Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii EditedV Pro Bp08505 Phase Iii Edited
V Pro Bp08505 Phase Iii Edited
 
V Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii EditedV Pro Bp08505 Phase Ii Edited
V Pro Bp08505 Phase Ii Edited
 
Intel® V Pro™ Technology
Intel® V Pro™ TechnologyIntel® V Pro™ Technology
Intel® V Pro™ Technology
 
XForms with Linux
XForms with LinuxXForms with Linux
XForms with Linux
 
XForms
XFormsXForms
XForms
 
Rails
RailsRails
Rails
 
Call
CallCall
Call
 
Action Mailer
Action MailerAction Mailer
Action Mailer
 
Ruby Security
Ruby SecurityRuby Security
Ruby Security
 
Web Services
Web ServicesWeb Services
Web Services
 
Pragmatic Agile Web Development With Rails.3rd Edition.2009
Pragmatic   Agile Web Development With Rails.3rd Edition.2009Pragmatic   Agile Web Development With Rails.3rd Edition.2009
Pragmatic Agile Web Development With Rails.3rd Edition.2009
 
Ruby Basics
Ruby BasicsRuby Basics
Ruby Basics
 
Ruby Installation
Ruby InstallationRuby Installation
Ruby Installation
 
Mysql Statments
Mysql StatmentsMysql Statments
Mysql Statments
 
Mysql Fun
Mysql FunMysql Fun
Mysql Fun
 
Mysql
MysqlMysql
Mysql
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 

AJAX ASP.Net

  • 1. The ASP.NET AJAX Extensions Robert A Dennyson
  • 2. Architecture ASP.NET 2.0 Page Framework & Server Controls Application Services ASP.NET AJAX Extensions Server Controls ASPX ASMX Application Services Bridge Asynchronous Communications
  • 3. Server Controls UpdatePanel Update- Progress Timer DragOverlay- Extender ScriptManager ScriptManager- Proxy ProfileService Script Management Partial-Page Rendering Futures CTP
  • 4.
  • 5. ScriptManager Schema <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot; EnablePartialRendering=&quot;true|false&quot; EnablePageMethods=&quot;true|false&quot; AsyncPostBackTimeout=&quot; seconds &quot; AsyncPostBackErrorMessage=&quot; message &quot; AllowCustomErrorsRedirect=&quot;true|false&quot; OnAsyncPostBackError=&quot; handler &quot; EnableScriptGlobalization=&quot;true|false&quot; EnableScriptLocalization=&quot;true|false&quot; ScriptMode=&quot;Auto|Inherit|Debug|Release&quot; ScriptPath=&quot; path &quot;> <Scripts> <!-- Declare script references here --> </Scripts> <Services> <!-- Declare Web service references here --> </Services> </asp:ScriptManager>
  • 6. Script References <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Scripts> <asp:ScriptReference Name=&quot;PreviewScript.js&quot; Assembly=&quot;Microsoft.Web.Preview&quot; /> <asp:ScriptReference Name=&quot;PreviewDragDrop.js&quot; Assembly=&quot;Microsoft.Web.Preview&quot; /> <asp:ScriptReference Path=&quot;~/Scripts/UIMap.js&quot; /> </Scripts> </asp:ScriptManager> &quot;Path&quot; references load script files &quot;Name&quot; references load script resources
  • 7. Service References <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Services> <asp:ServiceReference Path=&quot;ZipCodeService.asmx&quot; /> </Services> </asp:ScriptManager>
  • 8.
  • 9.
  • 10. UpdatePanel Schema <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot; EnablePartialRendering=&quot;true&quot; /> . . . <asp:UpdatePanel ID=&quot;UpdatePanel1&quot; Runat=&quot;server&quot; UpdateMode=&quot;Always|Conditional&quot; ChildrenAsTriggers=&quot;true|false&quot;> <Triggers> <!-- Define triggers (if any) here --> </Triggers> <ContentTemplate> <!-- Define content here --> </ContentTemplate> </asp:UpdatePanel>
  • 11.
  • 12. Triggers Example <asp:UpdatePanel ID=&quot;UpdatePanel1&quot; Runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;> <Triggers> <asp:AsyncPostBackTrigger ControlID=&quot;Button1&quot; /> <asp:AsyncPostBackTrigger ControlID=&quot;TreeView1&quot; EventName=&quot;TreeNodeExpanded&quot; /> <asp:AsyncPostBackTrigger ControlID=&quot;TreeView1&quot; EventName=&quot;TreeNodeCollapsed&quot; /> <asp:PostBackTrigger ControlID=&quot;Button2&quot; /> </Triggers> <ContentTemplate> ... </ContentTemplate> </asp:UpdatePanel>
  • 13.
  • 15.
  • 16. UpdateProgress Schema <asp:UpdateProgress ID=&quot;UpdateProgress1&quot; Runat=&quot;server&quot; DisplayAfter=&quot; milliseconds &quot; DynamicLayout=&quot;true|false&quot; AssociatedUpdatePanelID=&quot; UpdatePanelID &quot;> <ProgressTemplate> <!-- Declare UpdateProgress UI here --> </ProgressTemplate> </asp:UpdateProgress>
  • 17. UpdateProgress Example <asp:UpdateProgress DisplayAfter=&quot;500&quot; ...> <ProgressTemplate> <asp:Image ID=&quot;ProgressImage&quot; Runat=&quot;server&quot; ImageUrl=&quot;~/Images/SpinningClock.gif&quot; /> </ProgressTemplate> </asp:UpdateProgress> Animated GIF Display after ½ second
  • 18. Canceling an Update <asp:UpdateProgress DisplayAfter=&quot;500&quot; ...> <ProgressTemplate> <b>Working...</b> <asp:Button ID=&quot;CancelButton&quot; Runat=&quot;server&quot; Text=&quot;Cancel&quot; OnClientClick=&quot;cancelUpdate(); return false&quot; /> </ProgressTemplate> </asp:UpdateProgress> <script type=&quot;text/javascript&quot;> function cancelUpdate() { var obj = Sys.WebForms.PageRequestManager.getInstance(); if (obj.get_isInAsyncPostBack()) obj.abortPostBack(); } </script>
  • 20.
  • 21. Script-Callable Web Service [System.Web.Script.Services.ScriptService] public class ZipCodeService : System.Web.Services.WebService { [System.Web.Services.WebMethod] public string[] GetCityAndState (string zip) { ... } }
  • 22. Declaring a Service Reference <asp:ScriptManager ID=&quot;ScriptManager1&quot; Runat=&quot;server&quot;> <Services> <asp:ServiceReference Path=&quot;ZipCodeService.asmx&quot; /> </Services> </asp:ScriptManager> <script src=&quot;ZipCodeService.asmx/js&quot; type=&quot;text/javascript&quot;> </script>
  • 23. Consuming a Web Service ZipCodeService.GetCityAndState(&quot;98052&quot;, onCompleted); . . . function onCompleted (result) { window.alert(result); }
  • 24. Handling Errors ZipCodeService.GetCityAndState(&quot;98052&quot;, onCompleted, onFailed); . . . function onCompleted (result, context, methodName) { window.alert(result); } function onFailed (err, context, methodName) { window.alert(err.get_message()); }
  • 26. ASMX Wire Format POST /AtlasRC/ZipCodeService.asmx/GetCityAndState HTTP/1.1 Accept: */* Accept-Language: en-us Referer: http://localhost:1997/AtlasRC/ZipCodePage.aspx UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; ...) Host: localhost:1997 Content-Length: 15 Connection: Keep-Alive Cache-Control: no-cache {&quot;zip&quot;:&quot;98052&quot;} Request HTTP/1.1 200 OK Server: ASP.NET Development Server/8.0.0.0 Date: Fri, 29 Dec 2006 21:06:17 GMT X-AspNet-Version: 2.0.50727 Cache-Control: private, max-age=0 Content-Type: application/json; charset=utf-8 Content-Length: 16 Connection: Close [&quot;REDMOND&quot;,&quot;WA&quot;] Response JSON-encoded input JSON-encoded output
  • 27.
  • 28. ASMX Request Handling ScriptHandler- Factory RestClient- ProxyHandler RestHandler WebService- HandlerFactory *.asmx &quot;Normal&quot; ASMX calls ASMX Extensions *.asmx/js *.asmx/ methodname Helper Classes Default ASMX handler
  • 29.
  • 30. JSON vs. XML Point p = new Point(100, 200); {&quot;IsEmpty&quot;:false,&quot;X&quot;:100,&quot;Y&quot;:200} JSON <?xml version=&quot;1.0&quot;?> <Point xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;> <X>100</X> <Y>200</Y> </Point> XML
  • 31.
  • 32. Using ScriptMethod [System.Web.Script.Services.ScriptService] public class ZipCodeService : System.Web.Services.WebService { [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod (ResponseFormat=ResponseFormat.Xml)] public XmlDocument GetCityAndState (string zip) { ... } } Method returns XML document, so serialize as XML rather than JSON
  • 33.
  • 34. Enabling Page Methods <asp:ScriptManager ID=&quot;ScriptManager1&quot; EnablePageMethods=&quot;true&quot; Runat=&quot;server&quot; /> var PageMethods = function() { PageMethods.initializeBase(this); this._timeout = 0; this._userContext = null; this._succeeded = null; this._failed = null; } PageMethods.prototype = { ... }
  • 35. Defining a Page Method public partial class MyPage : System.Web.UI.Page { [System.Web.Services.WebMethod] public static string[] GetCityAndState (string zip) { ... } ... }
  • 36. Calling a Page Method PageMethods.GetCityAndState(&quot;98052&quot;, onComplete); . . . function onComplete(result) { window.alert(result); }
  • 38.
  • 39. Using AuthenticationService Sys.Services.AuthenticationService.login (username, password, false, null, null, onLoginCompleted, onLoginFailed); ... function onLoginCompleted(result, context, methodName) { window.alert(result ? 'Login succeeded' : 'Login failed'); } function onLoginFailed(err, context, methodName) { window.alert(err.get_message()); }
  • 40. Loading Profile Properties Sys.Services.ProfileService.load(['ScreenName'], onLoadCompleted, onLoadFailed); ... function onLoadCompleted(result, context, methodName) { window.alert(Sys.Services.ProfileService.properties.ScreenName); } function onLoadFailed(err, context, methodName) { window.alert(err.get_message()); } Pass null to load all profile properties
  • 41. Saving Profile Properties Sys.Services.ProfileService.properties.ScreenName = 'Bob'; Sys.Services.ProfileService.save(['ScreenName'], onSaveCompleted, onSaveFailed); ... function onSaveCompleted(result, context, methodName) { window.alert('Save succeeded'); } function onSaveFailed(err, context, methodName) { window.alert(err.get_message()); } Pass null to save all profile properties

Editor's Notes

  1. If no event name is specified in a trigger, the trigger automatically references the control&apos;s default event (e.g., Button.Click)
  2. Call Web service and use WDH to show traffic on the wire.
  3. One of the &amp;quot;Helper Classes&amp;quot; is WebServiceClientProxyGenerator , which RestClientProxyHandler calls upon to generate JavaScript proxies.
  4. ASP.NET AJAX’s JSON serializers provide special handling for one common .NET data type that isn’t handled natively by JSON: System.DateTime . Here’s how System.Web.Script.Serialization.JavaScriptSerializer serializes a date and time representing midnight on January 1, 2000 into JSON: &amp;quot;@946702800000@&amp;quot; The number between @ signs is the number of milliseconds elapsed since January 1, 1970. This is the format used by the ASP.NET AJAX Release Candidate (RC); it will probably be tweaked before RTM.
  5. The first null passed to the login function is used to pass custom data. The second null is a redirect URL. If a redirect URL is specified, the user is redirected to that location following a successful login. The third parameter to the login function specifies whether a logged-in user should be issued a temporary auth cookie (false) or a persistent auth cookie (true). In order for all this to work, the application&apos;s authentication mode must be set to &amp;quot;Forms.&amp;quot;