2012-08-23 35 views
0

如何從ActionLink asp.net Mvc 3調用jquery函數?

如何從actionlink調用jquery函數。我的this.href結果爲: 「localhost:54678/Customer?param = 1」但我需要this.href: 「localhost:54678/Customer/EditCustomer /?param = 1」 Customer是Controller,EditCustomer是Action。

的Jquery:


    $('#mylink').click(function (e) { 
      jQuery('#dialog').dialog('open'); 
      var iframe = $('#frame'); 
      alert(this.href); 
      $(iframe).attr('src', this.href); 

      e.preventDefault(); 
     }); 

查看:



    <%= Html.ActionLink(
      "Click", 
      "Index", 
    new { param = 1 }, 
    new { id = "mylink" }) 
%> 

本地主機:54678 /客戶/ EditCustomer /參數= 1如何調用這個?

回答

1

這個怎麼樣?

<%= Html.ActionLink( 
     "Click", 
     "EditCustomer", 
new { param = 1 }, 
new { id = "mylink" }) 

%>

0

你的ActionLink是指向客戶控制器的索引行爲。將其更改爲EditCustomer,如下所示:

<%= Html.ActionLink(
      "Click", 
      "EditCustomer", 
    new { param = 1 }, 
    new { id = "mylink" }) 
%>