我尝试更新模型属性值,但在httpost中没有反映输入的新值,显示原始值。 谢谢你的帮助。
<div class="row row-padding">
<section class="form-field">
<input asp-for="bidDataProcess.MaxBidPosted" type="number" class="form-control" />
<form asp-controller="Item" asp-action="PlaceBid" asp-route-ItemId="@Model.itemDescription.ItemId" asp-route-MaxBid="@Model.bidDataProcess.MaxBidPosted" method="post" class="clearfix">
<input id="PlaceBid" type="submit" style="background-color:blue;color:white; font-weight:bold;width:50%" class="form-control text-center" value="Place Bid" />
</form>
</section>
<小时/>
[HttpPost]
public ActionResult PlaceBid(int ItemId, decimal MaxBid)
{
// Maxbid resturns the original value not the new value entered.
decimal maxBid = MaxBid;
return View();
}
答案 0 :(得分:0)
CSHTML:
<div class="row row-padding">
<section class="form-field">
<form asp-controller="Item" asp-action="PlaceBid" asp-route-ItemId="@Model.ItemId" method="post" class="clearfix">
<input asp-for="MaxBidPosted" type="number" class="form-control" />
<input id="PlaceBid" type="submit" style="background-color:blue;color:white; font-weight:bold;width:50%" class="form-control text-center" value="Place Bid" />
</form>
</section>
</div>
控制器:
[HttpPost]
public ActionResult Index(int ItemId, decimal MaxBidPosted)
{
decimal maxBid = MaxBidPosted;
return View();
}