2013-03-27 27 views
0

用户点击按钮,按钮载入JQuery的对话框,用户点击“删除”和2倍的值传递给DeleteInvoice()上WorkItemMgr.cs传递多个值到JS的功能和回C#

<input id="RemoveInvoice" type="button" value="Remove Invoice" onclick="ConfirmDeleteInvoice('<%:TempInvoiceId%>', '<%:InvoiceId %>')" />               

     $("#RemoveInvoice").click(ConfirmDeleteInvoice); 

     function ConfirmDeleteInvoice(InvoiceId, SiteIdentifier) { 
      $("#dialog-confirm").dialog({ 
       resizable: false, 
       height: 180, 
       modal: true, 
       buttons: { 
        Delete: function() { 
         WorkItemMgr.DeleteInvoice(InvoiceId, SiteIdentifier); 
         $(this).dialog("close"); 
        }, 
        Cancel: function() { 
         $(this).dialog("close"); 
        } 
       } 
      }); 
     } 

我有通过一个断点来处理它,并且传递了2个正确的值,但在WorkItemMgr.DeleteInvoice(InvoiceId,SiteIdentifier)中出现错误。

错误:JavaScript的运行时错误:对象不支持属性或方法 'DeleteInvoice'

DeleteInvoice是一个WebMethod ...

[WebMethod] 
protected string DeleteInvoice(int InvoiceId, int SiteIdentifier) 
{ 
+0

将不得不调用与'$ .ajax' – tymeJV 2013-03-27 17:13:21

+0

该Web方法你添加的ScriptManager到网页看看这个:http://geekswithblogs.net/frankw /archive/2008/03/13/asp.net-ajax-callbacks-to-web-methods-in-aspx-pages.aspx – Floremin 2013-03-27 17:15:29

+0

你应该真的使用signalR – 2013-03-27 17:22:15

回答