2011-07-28 99 views
1

以下是我對一個服務器端方法的PageMethod調用的實現。它當前正在生成此錯誤消息「未捕獲的ReferenceError:PageMethod未定義」。我可以在Chrome Javascript控制檯中看到此錯誤。我的研究表明,PageMethods最常見的問題是忘記將EnablePageMethods設置爲「true」(做到了這一點),並且需要重新構建應用程序(也是這樣做)。我現在很難過。任何人都可以發現我做錯了什麼嗎?PageMethod未定義的錯誤

腳本管理:

<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> 

代碼背後:

[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

回答

4

嘗試

PageMethods.RemovePackagePageMethod(PackageID); 

(具有小號 - PageMethods代替PageMethod的)

+0

就是這樣。謝謝。我不能相信我沒有抓到! – hughesdan