標籤:style blog http color io os 使用 ar java
1:從網上下載:AjaxPro.2.DLL檔案,:
http://files.cnblogs.com/wequst/AjaxPro.2.zip
2:解壓之後把DLL放到程式bin目錄下進行參照引用。
3:在WEB.config檔案中進行載入使用:添加以下代碼:
<httpHandlers><add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/></httpHandlers>
4:建立測試的VB.net WEB表單程式
AjaxTest.aspx
5:在上面頁面的後台LOAD事件塊中添加以下的代碼進行DLL的註冊載入:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load AjaxPro.Utility.RegisterTypeForAjax(GetType(AjaxTest))End Sub
6:在後台中添加需要前台調用的函數
<AjaxPro.AjaxMethod()> Public Function fnAjaxTest(ByVal name As String) Return (name) End Function
7:前台HTML代碼
<body> <form id="form1" runat="server"> <div> <input id="Button1" type="button" value="button" onclick="getajax();" /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form></body>
8:JS中調用後台代碼
<head runat="server"> <title>無標題頁</title> <script type="text/javascript"> function getajax() { alert(‘222‘); WebApplication1.AjaxTest.fnAjaxTest(‘aa‘); document.getElementById("Label1").innerHTML=‘testaJAX‘; alert(‘3333‘); } </script></head>
這樣完成以上的步驟,整個JS調用背景過程就實現了。
VB.net中Ajaxpro的使用