Saturday, July 30th, 2005
Elegant ASP.NET Library for Ajax
<>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:











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