1 / 9

AJAX Now with ASP.NET 2.0

AJAX Now with ASP.NET 2.0. Jim Zimmerman. AGENDA. Overview of AJAX Client Script Callbacks in ASP.NET 2.0 Demo using Script Callbacks Demo using Jason Diamond’s Library Atlas AJAX for .NET 1.1 Where to go from here?. Overview of AJAX. Asynchronous JavaScript+CSS+DOM+XMLHttpRequest

Audrey
Download Presentation

AJAX Now with ASP.NET 2.0

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. AJAX Now with ASP.NET 2.0 Jim Zimmerman

  2. AGENDA • Overview of AJAX • Client Script Callbacks in ASP.NET 2.0 • Demo using Script Callbacks • Demo using Jason Diamond’s Library • Atlas • AJAX for .NET 1.1 • Where to go from here?

  3. Overview of AJAX • Asynchronous JavaScript+CSS+DOM+XMLHttpRequest • Remote Scripting • Who’s Using AJAX • Google Maps, Gmail, Suggest • Yahoo Flickr • Microsoft Outlook Web Client • Ajax isn’t something you can download • Don’t need to use XML

  4. Client Script Callbacks • New to ASP.NET 2.0 • Are similar to Postbacks in .NET 1.1 • Works cross-platform. • ICallbackEventHandler Problems • Interface has a single method and any callback to the page goes back to this single handler • Single handler has no context to tell which control it's dealing with • The RaiseCallbackEvent method can only accept a single string and return a single string

  5. Demo using Script Callbacks • Create a delegate for the ICallbackEventHandler • public MyAjax.EventControl ProductListEventControl = new MyAjax.EventControl(); • Generate the client script for the control • ProductListEventControl.ScriptCallback += new MyAjax.delScriptCallBack(GetProductDetails); • ScriptRef = this.GetClientScript(ProductListEventControl, "productList","GetProductDetails"); • this.productList.Attributes.Add("onchange", ScriptRef); • Create JavaScript handler for the result • function GetProductDetails(Result,Context) • { • // alert (Result); • Detail = document.getElementById('divContents') • Detail.style.display=''; • Detail.innerHTML = '<pre>' + Result + '</pre>'; • } • Limitations • ICallbackEventHandler.RaiseCallbackEvent method can only accept a single string and return a single string

  6. Demo using Jason’s Library • Jason Diamond created a library that was not dependent on use of a separate IHttpHandler implementation to process the callback requests like what is used in AJAX.NET • Register the script • Ajax.Manager.Register(this, "My.Page", Ajax.Debug.None); • Create the c# method in the code behind • [Ajax.Method] • public DataSet GetDataSet() • { • DataSet ds = new DataSet(); • ds.Tables.Add(GetDataTable()); • return ds; • } • Create the JavaScript • function PopulateListWithDataSet() { • My.Page.GetDataSet(DoSetCallBack); • document.getElementById("_popSetButton").value = "Getting DataSet..."; • }

  7. Atlas Client Script Framework • 100% JavaScript client framework • Make it real easy for developers • Will work on all modern browsers • The Atlas Client Script Framework will include the following components: • An extensible core framework that adds features to JavaScript such as lifetime management, inheritance, multicast event handlers, and interfaces • A base class library for common features such as rich string manipulation, timers, and running tasks • A UI framework for attaching dynamic behaviors to HTML in a cross-browser way • A network stack to simplify server connectivity and access to web services • A set of controls for rich UI, such as auto-complete textboxes, popup panels, animation, and drag and drop • A browser compatibility layer to address scripting behavior differences between browsers. • http://weblogs.asp.net/scottgu/archive/2005/06/28/416185.aspx

  8. AJAX for .NET 1.1 • http://ajax.schwarz-interactive.de/csharpsample/default.aspx- Michael Schwarz • http://jason.diamond.name/weblog/2005/07/06/my-ajax-dot-net-library- Jason Diamond

  9. Where to go from here? • Think about what situations would be enhanced by AJAX style coding • Download the demo source code and presentation at: • http://aspnet2examples.blogspot.com • Prototype AJAX friendly scenarios

More Related