2015-02-10 154 views
-1

在控制器我有功能public ActionResult Index(int id,int test= 0,int to=10){}我試圖改變價值測試從單擊視圖獲取測試+ = 10,但我不知道如何。我嘗試了與行動鏈接和ajax,但它不工作。有任何想法嗎? 我的查看碼:如何將價值從視圖傳遞到控制器

<html ng-app> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title>Countries</title> 
    <link href="~/Content/style.css" rel="stylesheet" /> 
    <link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" /> 

</head> 
<body> 
    <div> 
     <table> 
      <tr> 
       <td><h3>Matches</h3></td> 
      </tr> 
      <tr> 

      </tr> 
      @foreach (var i in Model.ListMatch) 
      { 

       <tr> 
        <td>@Html.ActionLink(i.Description, "", new { id = i.Id })</td> 

       </tr> 




      } 

     </table> 
    </div> 
</body> 
</html> 

我將結果返回到ng-view。我可以這樣做

<a href="@Url.Action("Index", "Countries",new { id = i.Id, from+=10 })"></a> 
+0

請顯示您的查看代碼。 – Robert 2015-02-10 15:01:09

+0

有我的看法代碼 – None 2015-02-10 15:06:03

+0

你想添加10到服務器的每次調用中的變量嗎? – AnotherGeek 2015-02-10 17:52:57

回答

0

這個問題是不是很好的解釋,但是從我猜想你要能夠做出改變的值,而不重新加載頁面或退出了這一觀點。

爲了做到這一點,你必須使用AJAX。我知道你說過你嘗試過AJAX,但也許你錯了。試試這個:

$('#yourbutton').click(function() { 
    $.post("/YourController/YourFunction", function() { 
     alert("success"); 
    }); 
}); 
相關問題