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
- Make reference in your project to the AJAX.NET Framework
- Add an httpHandler to your web.config
- Register your page as an AJAX.NET Framework page
- Decorate your methods with the [Ajax.AjaxMethod()]
- 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: