Original article address: http://www.ajaxpro.info/quickguide.aspxajaxproquick start
Because I cannot write a lot of user documents, this article only tells you how to use AjaxPro:
- You can download the latest Ajax. NET Professional file from the www.schwarz-interactive.de
- Add reference AjaxPro.2.dll to your project (use AjaxPro. dll for. NET 1.1 Framework)
- Add the following content to your web. config:
<?xml version="1.0" encoding="utf-8" ?><configuration> <system.web> [...] </system.web></configuration>
- Now you can use the AjaxMethod property to add your. NET method:
[AjaxPro.AjaxMethod]public DateTime GetServerTime(){ return DateTime.Now;}
- To use JavaScript on the client to call your. net method, you must register your page class to Ajax. NET:
namespace MyDemo{ public class _Default { protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default)); } [AjaxPro.AjaxMethod] public DateTime GetServerTime() { return DateTime.Now; } }}
- You can use JavaScript Asynchronous Method on the client to call your. net method:
Function getServerTime () {MyDemo. _ Default. GetServerTime (getServerTime_callback); // asynchronous call} // after this method is executed, the following method will be called
// The result will be returned to the client function getServerTime_callback (res) {alert (res. value );}
- You can also use the JavaScript synchronization method on the client to call your. net method:
function getServerTime(){ alert(MyDemo._Default.GetServerTime().value;
}