[AjaxPro.AjaxMethod]这是干嘛的?应用实例如下:
#region 检测用户名是否存在
[AjaxPro.AjaxMethod]问题:这句代码的作用是什么?去掉可以吗???
public bool IsExistUser(string strUserName, string Level)
{
bool flag = new M_BLL.T_User().IsUser(strUserName, Level);
return flag;
}
#endregion 检测用户名是否存在
#region 检测用户名是否存在
[AjaxPro.AjaxMethod]问题:这句代码的作用是什么?去掉可以吗???
public bool IsExistUser(string strUserName, string Level)
{
bool flag = new M_BLL.T_User().IsUser(strUserName, Level);
return flag;
}
#endregion 检测用户名是否存在
需要在方法前加上这玩意
代表该方法是ajax方法,
[AjaxPro.AjaxMethod]是AjaxPro库的ajax特性标签,指示方法由AjaxPro库来处理 一个标签注册在方法上
前台AJAXPRO可以调这个方法。
public static string GetMessage()
{
return "message";
}
前提js调用<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function test() {
PageMethods.GetMessage(success);
} function success(result) {
alert(result);
}
</script></head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<input id="Button1" type="button" value="button" onclick="test()" />
</div>
</form>
</body>
</html>
ScriptManager 必须设置成 EnablePageMethods="true"