PageMethod Undefined Error
The following is my implementation of a PageMethod call to a server-side method. It is currently generating this error message "Uncaught ReferenceError: PageMethod is not defined". I can see this error in the Chrome Javascript console. My research suggests that the most common problems with PageMethods are forgetting to set EnablePageMethods to "true" (did that) and needing to rebuild the application (did that 开发者_如何学Pythontoo). I'm stumped now. Can anyone spot what I've done wrong?
Script Manager:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true">
ASPX:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function confirmCallBackFn(arg) {
if (arg == true) {
var firstDataItem = $find("<%=RadGrid1.ClientID %>").get_masterTableView().get_dataItems()[0];
var PackageID = firstDataItem.getDataKeyValue("PackageID");
PageMethod.RemovePackagePageMethod(PackageID);
}
else {
}
}
</script>
</telerik:RadCodeBlock>
Code Behind:
[WebMethod()]
public static void RemovePackagePageMethod(int PackageID)
{
Inventory inv = new Inventory();
inv.RemovePackage(PackageID);
}
public void RemovePackage(int PackageID)
{
SBMData2.SBMDataContext db = new SBMData2.SBMDataContext();
var boxes = from p in db.Packages
where p.PackageID == PackageID
select p;
foreach (var box in boxes)
{
db.Packages.DeleteOnSubmit(box);
}
try
{
db.SubmitChanges();
RadGrid1.Rebind();
}
catch (Exception ex)
{
RadWindowManager1.RadAlert("System error deleting package", 200, 200, "exception", null);
}
}
d
try
PageMethods.RemovePackagePageMethod(PackageID);
(with an s - PageMethods instead of PageMethod)
精彩评论