Saturday, July 30th, 2005

Elegant ASP.NET Library for Ajax

Category: .NET

<>p> Fexis Vargas pointed us to Jason Diamond, a DevelopMentor instructor, who has created his own Ajax library for making callbacks to the code behind an ASP page. It started out as an “intellectual exercise”, but he did such a good job, its turning into an open source project, whether he likes it or not :-).

Using his library, developers can write callback methods into the class like this:

public class WebForm1 : Page {
    void Page_Load() {
        Ajax.Manager.Register(this);
    }
	
    [Ajax.Method] double Add(double a, double b) {
        return a + b;
    }
}

and then from the ASP template reference the callback in this manner:

<input id="a" /> + <input id="b" /> = <input id="c" /><br />
<input type="button" value="Add"
    onclick="document.getElementById('c').value = 
    ASP.WebForm1_aspx.Add(document.getElementById('a').value,               
    document.getElementById('b').value);" />

Pretty slick.

Related Content:

Posted by Ben Galbraith at 9:43 am
1 Comment

++---
2.7 rating from 11 votes

1 Comment »

Comments feed

j.d.s.
http://www.burzs.com/edit/arg.php?id=14118

Comment by adf — February 13, 2007

Leave a comment

You must be logged in to post a comment.