前提:配置好应用AJAX的环境
1项目添加AjaxPro.dll引用 2在web.config文件中加入以下配置信息
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false"/>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
前台脚本方法:
<script language="jscript">
function IsUsernameExist_callback(result)
{
var value = result.value;
if( value == '0' )
{
location.href = "Index.aspx";
}
else
{
alert("请输入正确的用户密码!");
}
}
function VerifyUserName(name,pwd)
{
Login.GetReturnCode(name,pwd,IsUsernameExist_callback);
}
</script>
后台Ajax方法:
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public string GetReturnCode(string strUserNo, string strUserPassword)
{
return IsUsernameExist(strUserNo, strUserPassword) == false ? "1" : "0";
}
private bool IsUsernameExist(string strUserNo, string strPassWord){...}