语句的作用:页面注册方法的作用。
AjaxPro.Utility.RegisterTypeForAjax(typeof(命名空间.类名));
RegisterTypeForAjax代码应用演示:
Default.aspx.cs
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
}
[AjaxPro.AjaxMethod]
public int result(String userName)
{
if (userName.equals(String.Empty))
{
return -1;
}
else
{
//TODO:
return 0;
}
}
}Default.aspx代码:
<%@ Page Language="C#" 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>
<script language="javascript">
function checkUserName() {
var userName = document.getElementById('Text1').value;
if (_Default.result(userName).value = "-1") {
info.innerHTML = "Error";
}
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input id="Text1" type="text" onfocusout="return checkUserName()" />
</form>
</body>
</html>特别注意:使用AjaxPro注册的方法,在请求的页面上一定得有form表单,否则页面上将无法访问到AjaxPro.AjaxMethod标记的方法