添加组件引用后添加命名空间:using AjaxPro;
if(!this.IsPostBack)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(logon));
}
web.config
<system.web>
<httpHandlers>
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>
</httpHandlers>
.............
</system.web>
logon.aspx
function oSubmit(email,pwd)
{
test.logon.LogonIn(email, pwd, IsoSubmit_callback);
}
function IsoSubmit_callback(res)
{
if(res.value.substr(0,1)=="<")
document.getElementById("errMsg").innerHTML = res.value;
else
document.location.href = res.value;
}
<INPUT id="Button2" class="btn" type="submit" value="Login" onclick="oSubmit(Email.value,Password.value);">
logon.aspx.cs
[AjaxPro.AjaxMethod]
public string LogonIn(string e, string p)
{
//.........
}
第一次点登陆的时候提示“对象不支持此属性或方法”以后再点提示“test未定义”