Ajax|javascript|xml
Download Ajax.dll http://ajax.schwarz-interactive.de/csharpsample/default.aspx
The first example suggests a reference to its quickguide, it feels good
and quote here.
AJAX. Net Wrapper Quick Usage Guide
Karl seguin-http://www.openmymind.net/-Copyright 2005
(View Ajaxguide.doc For more detailed information)
Step 1-
Create a reference to the Ajax.dll file
Step 2-set up the HttpHandler
In the web.config, set up the HttpHandler, like:
...
Step 3-
In the Page_Load event, call the following function:
' VB.net
Public Class Index
Inherits System.Web.UI.Page
Private Sub Page_Load (sender as Object, e as EventArgs) Handles MyBase.Load
Ajax.Utility.RegisterTypeForAjax (GetType (Index))
'...
End Sub
'...
End Class
C#
public class index:system.web.ui.page{
private void Page_Load (object sender, EventArgs e) {
Ajax.Utility.RegisterTypeForAjax (typeof (Index));
//...
}
//...
}
Step 4-
In the codebehind of your page, add functions (like your normally would) that you ' d like to be able to asynchrounsly called by Client-side scripting. Mark functions with the Ajax.javascriptmethodattribute ():
C#
[Ajax.ajaxmethod ()]
public int Serversideadd (int firstnumber, int secondnumber)
{
return firstnumber + secondnumber;
}
' VB.net
_
Public Function Serversideadd (ByVal firstnumber As Integer, ByVal secondnumber As Integer) As Integer
return Firstnumber + Secondnumber
End Function
The wrapper would automatically create a JavaScript function named "Serversideadd" which accepts to parameters. When called, this server-side function is called and the result returned.
Step 5-
Using JavaScript, you can invote the Serversideadd function like your would any other JavaScript function. You can call it using the two parameters, or optionally pass a call back function. The name of the "function is", by default, ., such as Index.servers Ideadd:
Alertindex.serversideadd (100,99));
OR
Index.serversideadd (100,99, serversideadd_callback);
function Serversideadd_callback (response) {
alert (Response.value);
}
The response exposes three properties, error, value and request.
Note This can return to more complex objects the simple types.
The demo For additional information:
Http://ajax.schwarz-interactive.de/csharpsample/default.aspx
It's the first example you've ever modeled, and hopefully more people will be involved.