Publish Date: 12/6/2005
What's New?
- 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: