Craig Shoemaker

<September 2008>
SuMoTuWeThFrSa
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011


Navigation

The Roll

Subscriptions

News

Check out the Podcast
Polymorphic Podcast - the show about object oriented development, architecture and best practices in .NET
Subscribe to the Blog
ASP.NET 2.0 AJAX
Beginning Ajax with ASP.NET

Post Categories



Podcast: Using the AJAX.NET Framework

For more information go to PolymorphicPodcast.com

Take the listener survey!

You could win a $30 gift certificate to Amazon.com

What's New?

  • Archives - I posed all of the old shows that I previously had to remove. Check them out at the bottom of the homepage.

  • I'm a junkie! The blog is now over at DotNetJunkies.com. If you have subscribed to the blog, no worries you don't have to change anything on your end :)

  • Check out the Wally McClure's Atlas talk, which is a sister show to this one

Featured CoDe Magazine Content

LINQ by Yair Alan Griver

Using the AJAX.NET Framework

Introduction

The AJAX.NET Framework is a simple-to-use framework that wrapps up most of the plumbing of using AJAX.

There only a few actions you have to take to empower your application with the AJAX.NET framework

  1. Make reference in your project to the AJAX.NET Framework
  2. Add an httpHandler to your web.config
  3. Register your page as an AJAX.NET Framework page
  4. Decorate your methods with the [Ajax.AjaxMethod()]
  5. Call your method in JavaScript using the type name of your page

Here are some examples:

1) Set Reference

No example necessary.

2) HttpHandler

Provide a way for the AJAX.NET Framework to look at each request and determine if it need to do anything.

<httpHandlers>
	<add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax" />
</httpHandlers>
                

3) Register Page

You register with the type of the page you are registering.

Ajax.Utility.RegisterTypeForAjax(typeof(_default));
                

4) Use the Ajax.AjaxMethod Attribute

Here is a sample method.

[Ajax.AjaxMethod()]
public TaskCollection GetTasks()
{
    return WebAppConfig.Tasks;
}
                

5) Use the Page Type Name in JavaScript

You call the function in JavaScript using the type name of your page as the object. You may optionally pass in a parameter that will use a call back method when the action is complete.

function GetTasks()
{
    _default.GetTasks(GetTasks_CallBack);
}

function GetTasks_CallBack(response)
{
    if(IsValidResponseValue(response))
    {
        LoadTasks(response.value);
    }
}
                

Support Provided by:

    posted on Tuesday, December 06, 2005 9:01 AM by drazz75





    Powered by Dot Net Junkies, by Telligent Systems