aspx .net AjaxPro2使用说明
AjaxPro2使用说明 AjaxPro.2首先下载Ajax.Net,你可以从这里获得。最新版本,下载解压后的文件夹中有个AjaxPro.2.dll,就是它了。使用VS2005以上的新建web项目(注意,AjaxPro.2.dll不支持VS2003),并添加对AjaxPro.2.dll的引用,然后在Web配置文件中添加: <httpHandlers> <!--ajaxpro--> <addpath="ajaxpro/*.ashx"verb="*"type="AjaxPro.AjaxHandlerFactory,AjaxPro.2" /> </httpHandlers>
Cs类 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using AjaxPro; namespace Login { [AjaxNamespace("ajax")]//这个命名空间很重要 public partial class Login : System.Web.UI.Page { protectedvoid Page_Load(objectsender,EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Login),this.Page); //注册本界面到ajaxPro中; } [AjaxPro.AjaxMethod] public string GetServerTime (stringname, string pass) { Return DateTime.Now.ToString(); }
} } Js中调用方法如下: <scripttype="text/javascript"> function getTime() { alert(ajax.GetServerTime().value); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |