我是新來的Asp.Net MVC,我無法弄清楚如何更新部分視圖後的數據。我對GET沒有問題,並在局部視圖中顯示數據。在局部視圖中更新數據
我不知道在哪裏把部分視圖數據的郵政編碼放在父頁的郵政方法中?或部分視圖的後期方法?
當我運行下面的代碼時,我提交時會收到此消息。
}
它發現在初始頁面加載控制「公共行動方法‘ScoreRelease’是不是在控制‘Registration.Web.Controllers.AgreementsController’。發現」,而不是當我打電話返回查看(「查看」);在post方法中。
Parial查看從 「評論」 頁面
@{Html.RenderAction("ScoreRelease", "Agreements");}
ScoreRelease管窺
@model Registration.Web.Models.ReviewModel.ReleaseScore
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<div class='group' id='data_release'>
<h4>
Data Release
</h4>
<p>
Do you wish to release your scores?
</p>
<ul class='input_group'>
<li>
@Html.RadioButtonFor(model => model.ReleaseScoreIndicator, true)
<label>
Yes
</label>
</li>
<li>
@Html.RadioButtonFor(model => model.ReleaseScoreIndicator, false)
<label>
No
</label>
</li>
</ul>
<input type="submit" value="Save" />
</div>
}
查看控制器
public ActionResult Review()
{
return View();
}
[HttpPost]
public ActionResult Review(ReviewModel.ReleaseScore model)
{
var agmtsService = new AgreementsService();
agmtsService.UpdateReleaseScoreIndicator(model.ReleaseScoreIndicator);
return View("Review");
}
[HttpGet]
public ActionResult ScoreRelease()
{
var agmtsService = new AgreementsService();
bool scoreRelease = agmtsService.GetReleaseScoreIndicator();
var vm = new ReviewModel.ReleaseScore();
vm.ReleaseScoreIndicator = scoreRelease;
return PartialView(vm);
}