不错呦!smile@林凯西,确保“准备文件”中的几个文件都有安装,S...您好,看了您这篇帖子觉得很有帮助。但是有个问题想请...我的修改过了怎么还被恶意注册呢 @jjjjiiii 用PJ快9年了,主要是A...PJ3啊,貌似很少有人用PJ了,现在不是WP就是z...@332347365,我当时接入时错误码没有-10...楼主,ChkValue值应为-103是什么意思呢?...大哥 你最近能看到我发的信息,请跟我联系,我有个制...
一个简单的AjaxPro使用案例
编辑:dnawo 日期:2008-09-06
准备工作:
1.登录 http://www.ajaxpro.info/ 下载AjaxPro;
2.在项目中添加对AjaxPro.2.dll的引用;
3.在Web.config中增加location节点:
使用案例:
Default.aspx:
Default.aspx.cs:
说明:
1.必须在Page_Load注册AjaxPro;
2.AjaxPro的方法必须在前边加[AjaxPro.AjaxMethod],且访问级别一定要是public;
3.客户端使用"类名.方法名(参数列表,回调函数)"的形式直接调用服务器端函数;
1.登录 http://www.ajaxpro.info/ 下载AjaxPro;
2.在项目中添加对AjaxPro.2.dll的引用;
3.在Web.config中增加location节点:
复制内容到剪贴板 程序代码
<configuration>
<location path="ajaxpro">
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
</location>
</configuration>
<location path="ajaxpro">
<system.web>
<httpHandlers>
<add verb="*" path="*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro.2"/>
</httpHandlers>
</system.web>
</location>
</configuration>
使用案例:
Default.aspx:
复制内容到剪贴板 程序代码
<%@ 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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="MyDIV"></div>
<input id="Button1" type="button" onclick="_Default.GetValueA('mzwu.com',callback);" value="GetValueA" />
<input id="Button2" type="button" onclick="_Default.GetValueB('mzwu.com',callback);" value="GetValueB" />
<script type="text/javascript">
function callback(val)
{
document.getElementById("MyDIV").innerHTML = val.value;
}
</script>
</div>
</form>
</body>
</html>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="MyDIV"></div>
<input id="Button1" type="button" onclick="_Default.GetValueA('mzwu.com',callback);" value="GetValueA" />
<input id="Button2" type="button" onclick="_Default.GetValueB('mzwu.com',callback);" value="GetValueB" />
<script type="text/javascript">
function callback(val)
{
document.getElementById("MyDIV").innerHTML = val.value;
}
</script>
</div>
</form>
</body>
</html>
Default.aspx.cs:
复制内容到剪贴板 程序代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//注册AjaxPro,括号中的参数是当前的类名
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
//标记,查看页面是否刷新
Response.Write(DateTime.Now);
}
/// <summary>
/// 在字符串前加AAA_
/// </summary>
/// <param name="strTemp"></param>
/// <remarks>具有 AjaxPro.AjaxMethod 特性</remarks>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string GetValueA(string strTemp)
{
return "AAA_" + strTemp;
}
/// <summary>
/// 在字符串前加BBB_
/// </summary>
/// <param name="strTemp"></param>
/// <remarks>具有 AjaxPro.AjaxMethod 特性</remarks>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string GetValueB(string strTemp)
{
return "BBB_" + strTemp;
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//注册AjaxPro,括号中的参数是当前的类名
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
//标记,查看页面是否刷新
Response.Write(DateTime.Now);
}
/// <summary>
/// 在字符串前加AAA_
/// </summary>
/// <param name="strTemp"></param>
/// <remarks>具有 AjaxPro.AjaxMethod 特性</remarks>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string GetValueA(string strTemp)
{
return "AAA_" + strTemp;
}
/// <summary>
/// 在字符串前加BBB_
/// </summary>
/// <param name="strTemp"></param>
/// <remarks>具有 AjaxPro.AjaxMethod 特性</remarks>
/// <returns></returns>
[AjaxPro.AjaxMethod]
public string GetValueB(string strTemp)
{
return "BBB_" + strTemp;
}
}
说明:
1.必须在Page_Load注册AjaxPro;
2.AjaxPro的方法必须在前边加[AjaxPro.AjaxMethod],且访问级别一定要是public;
3.客户端使用"类名.方法名(参数列表,回调函数)"的形式直接调用服务器端函数;
上一篇: Windows服务中Timer组件Tick无法触发解决方法
下一篇: AjaxPro使用之各类型数据(String/List/DataTable)的传递和显示
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
下一篇: AjaxPro使用之各类型数据(String/List/DataTable)的传递和显示
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
最新日志:
评论: 0 | 引用: 0 | 查看次数: 4051
发表评论
请登录后再发表评论!