Thursday, June 5, 2008

Thurs, 10:15am -- Deep Dive into the ASP.Net AJAX Extensions

Thurs, 10:15am -- Deep Dive into the ASP.Net AJAX Extensions
Jeff Prosise --Cofounder, Wintellect www.wintellect.com

Architecture:

ASPX and ASMX

ASP.Net AJAX Extensions
• Server Controls
• Application Services Bridge
• Asynchronous Communications

ASP.Net

• Framework & Server Controls
• Application Controls

Server Controls
• Script Manager – Starting point for asp.net ajax pages
• downloads javascript files to client enables partial page rendering using update panel
• Provides client side proxies for web services
• manages callback timeouts and provides error handling
• options and infrastructure
• Provides registration methods for scripts
• Enables ASP.Net AJAX localization support
• Every page requires one script manager

AllowCustomErrorsRedirect – so you can provide error handling

ScriptManagerProxy--
Proxy in content pages of ScriptManager controls declared in master pages
Lets content pages declare page-specific script and service references

UpdatePanel –
Partial-page rendering in a box
Clean round trips to server and flicker-free updates
Requires no knowledge of javascript or ajax
Leverages client-side PageRequestManager
EnablePartialRendering = true

Content Template and Triggers Element –

Triggers—used to reach outside of update panel to things that need to kick off a partial-postback.

1) script manager
2) update panel
3) put content template inside (with all markup inside that)

Now it no longer needs to do full postback (no blink)..it only does a partial and update the image

Downside of update panel –
Too much viewstate kills performance.

Web Development Helper – plug-in that is very useful to analyze traffic (get download)

30 or over of viewstate is too much

PageRequestManager – it is the key to customizing the update panel. It’s a clientside object that contains guts of update panel
Exposes a javascript API. By being aware of PRM you can allows conditional triggers.

UpdateProgressSchema—useful for progress bars, etc. Just display though, no percentage is available.
Update Cancellation – by capturing isInAsyncPostBack and then doing obj.abortPostBack.

Two update panels can update in one round trip to the server.

ASP.NET AJAX Web Services

ASP.NET AJAX support ASMX Web methods as endpoints for asynchronous AJAX callbacks
Efficient on the wire (no SOAP or XML)
Efficient on the server (no page lifecycle)
ScriptService attribute on server indicates Web service is callable from client-side script
JavaScript proxy on client enables …
To call a web service, create a service Reference
Handling Errors – create handling
(i.e. onFailed (err, context, methodName) { alert(msg); }


NOTE: Can create an autoFill function instead of using updatepanel for performance enhancement.

ASMX Wire Format
ASMX Request Handling
Script-Handler-Factory (lookup)
RestClient-ProxyHandler
RestHandler
Helper Classes
WebService-HandlerFactory

JSON—JavaScript Opject Notation (versus XML)
Used in AJAX. Lightweight data interchange format which is less expensive in serialized volume. However, JSON cannot handle a dataset, which is why XML is more powerful.

Page Methods:
Script-callable Web methods built into pages
Implemented in ASPXes, not ASMXes
Page scope rather than application scope
Same efficiencies as ASMX Web methods
Simpler than writing a full-blown Web service
Do not require service references
Do not require dedicated ASPX files
Must be public static methods
Called through PageMethods proxy on client
Note: Have to be static because they don’t have to run through a page lifecycle

Built-In Web Services
AuthenticationService
Front end to ASP.NET membership service
Called through built-in sys.services.authoenticationService proxy
ProfileService
Front-end to ASP.Net profile service
Called through sys.services.profileService proxy
RoleService(ASP.NET 3.5)
Front-end to ASP.NET role manager
Called through sys.services.roleservice proxy


Samples Link: http://wintelect.com/webdemos.aspx

Example: Burton Snowboards

No comments: