当前位置: 首页 > 工具软件 > AjaxPro > 使用案例 >

AjaxPro的简单应用

步弘和
2023-12-01

<httpHandlers>
       <add verb="POST,GET" path="AjaxProDemo/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
     </httpHandlers>                                                                                                                                  他的意思是所有的ajaxpro/*.ashx请求都由Ajax.PageHandlerFactory处理,而不是由默认的System.Web.UI.PageHandlerFactory处理程序工厂来处理.

4。编写服务器端的Ajax函数:                                                       他和普通的服务器方法唯一不同的地方就是他必须要在方法的上面添加个[AjaxPro.AjaxMethod]                                                            在Default.aspx的页面中加如下面的代码(几乎所有的Ajax的基础例子都是以做加法开始的。。。):                                                              [AjaxPro.AjaxMethod]
public string AddTwo(int firstInt, int secondInt)
{
     return Convert.ToString(firstInt + secondInt);
}

5。编写完成步骤4后在Page_Load里面把这个类注册一下                           protected void Page_Load(object sender, EventArgs e)
{
     AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
}

6。编写Default的前台代码了。。。                                                 <%@ Page Language="C#" AutoEventWireup="true"   CodeFile="Default.aspx.cs" Inherits="_Default" %>                                                          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">                    <html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <title>AjaxProUseDll</title>
     <script language="javascript" type="text/javascript">
     function addInt()
     {
         var i1 = document.getElementById('T1').value;
         var i2 = document.getElementById('T2').value;
         document.getElementById('B2').value = _Default.AddTwo(i1,i2).value;
     }
     </script>
</head>
<body>
     <form id="form1" runat="server">
     <div>
         <input type="text" id="T1" /> + <input type="text" id="T2" /> = <input type="button" id="B2" value="相加求和" οnclick="addInt()" />
     </div>
     </form>
</body>
</html>  
 

 类似资料: