我想在 javascript 中调用 Ajax,但它给出了 CallPageMethod 未定义的错误。如何定义它?我是阿贾克斯的新手。你能帮助我吗?
<script type="text/javascript">
function ValidateDelete() {
var result = CallPageMethod("IsLangExists", success, fail);
if (result == true) {
return confirm('Do you want to continue ?')
}
else alert('You can not delete this record');
}
function success(response) {
//alert(response.d);
}
function fail(response) {
//alert("An error occurred.");
}
</script>
<asp:GridView ID="grdList" OnRowCommand="grdList_RowCommand">
<Columns>
<asp:BoundField DataField="LangId" HeaderText="LangId" Visible="false" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:ImageButton ID="imgBtnDelete" runat="server" CommandName="_Delete" CommandArgument='<%#Eval("LangId")%>' ImageUrl="~/Image/delete_icon.gif" OnClientClick="return ValidateDelete();"
ToolTip="Delete" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
后面的代码
[WebMethod]
public static bool IsLangExists()
{
return true;
}