我用Razor和C#使用MVC。我想更新一個元素...與ajax計數器。這裏是我的代碼:如何將我的頁面中的值傳遞給控制器?
@model Domain.CounterObject
@using (Ajax.BeginForm("Count", "CounterObject", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "my-control" }))
{
<div id="my-control" class="bid-object">
<div>
<span class="title">@Html.Encode(Model.Title)</span>
</div>
<div>
<span class="display">@Html.Encode(Model.GetFinalDate())</span>
</div>
<div>
<span class="display">@Html.Encode(Model.GetValue())</span>
</div>
<div>
<input type="submit" value="Count" />
</div>
</div>
}
在我的控制器我有這樣的代碼:
[HttpPost]
public PartialViewResult Count(CounterObject counter)
{
// Special work here
return PartialView(counter);
}
的問題是,我收到我的計算方法我CounterObject櫃檯總是空。我如何將我的頁面的值傳遞給控制器?