1、下载Ajaxpro.2.dll

    程序中引用

  2、web.config配置

<?xml version="1.0" encoding="utf-8"?>

<!--
有关如何配置 ASP.NET 应用程序的详细消息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
--> <configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" /> <httpHandlers>
<!--<add verb="*" path="*/show-?*-?*.html" type="UrlRewriter" />-->
<add verb="*" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2" validate="false"/>
</httpHandlers>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="Index.aspx" />
</files>
</defaultDocument>
<handlers>
<add name="AjaxPro.AjaxHandlerFactory" path="ajaxpro/*.ashx" verb="*" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2" preCondition="integratedMode"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>

  

 3、页面中代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using System.Text; namespace HLBE.Admin
{
public partial class Gather : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(HLBE.Admin.Gather));
} [AjaxPro.AjaxMethod]
public string GetStr(string str)
{
return "213123";
}
}
}

  

  4、页面前段代码

  

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Gather.aspx.cs" Inherits="HLBE.Admin.Gather" %>

<!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></title>
<script language="javascript" type="text/javascript" src="../Js/JQuery.js"></script>
<script language="javascript" type="text/javascript">
function getServerTime() {
alert(HLBE.Admin.Gather.GetStr("1212").value);
} </script>
</head>
<body>
<form id="form1" runat="server">
</form>
<input id="Button1" type="button" value="button" onclick ="getServerTime();"/>
</body>
</html>

  5、注意地方

    页面中必须存在<form runat="server">表单,否则无法注册

  

05-01 05:03