有一个带有客户端和服务器端事件的 asp imagebutton。客户端方法通过 jQuery Ajax 调用 web 方法。在 OnSuccess 事件中,需要触发服务器端事件。
代码片段:
<asp:imagebutton id="imgbtn" runat="server" ImageUrl="/Images/icon.gif" OnClick="return CheckAPP();"></asp:imagebutton>
function CheckAPP() {
$.ajax({
type: "POST",
url: "testPage.aspx/ValidateSerialNumber",
data: "{strSerialNumber:'" + strSerialNumbers + "',strManufPartNo:'" + strMPartNo + "',strCountryCode:'" + '<%=strCountryCode %>' + "',strIpAddress:'" + '<%=strIpAddress.Trim %>' + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
return true;
},
failure: function (msg) {
return true;
}
});
}
Private Sub imgbtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgbtn.Click
SaveInfo()
End Sub