Asp.net 将输入文本中的值放入Html.BeginForm中的参数
我有Html.beginAsp.net 将输入文本中的值放入Html.BeginForm中的参数,asp.net,asp.net-mvc,razor,Asp.net,Asp.net Mvc,Razor,我有Html.begin @using (Html.BeginForm("AddMeals", "ClientReservations",new { overallCost= $('#mealsOverallCost').value })) 我读了下面的输入文本 <div id="DivMealsOverallCost"> @Html.Label("Całkowity koszt", htmlAttributes: new { @class = "contr
@using (Html.BeginForm("AddMeals", "ClientReservations",new { overallCost= $('#mealsOverallCost').value }))
我读了下面的输入文本
<div id="DivMealsOverallCost">
@Html.Label("Całkowity koszt", htmlAttributes: new { @class = "control-label col-md-2" })
<input type="text" id="mealsOverallCost" readonly="readonly" value="@ViewBag.OverallCost" />
</div>
不正确。您可以创建一个名称属性值为“overallCost”的隐藏输入表单元素,当您提交表单时,该元素将在请求正文中可用
@using (Html.BeginForm("AddMeals", "ClientReservations"))
{
<input type="text" id="mealsOverallCost" readonly="readonly"
value="@ViewBag.OverallCost" />
<input type="hidden" name="overallCost" value="@ViewBag.OverallCost" />
<input type="submit" />
}
@使用(Html.BeginForm(“addfends”、“clientervations”))
{
}
@using (Html.BeginForm("AddMeals", "ClientReservations"))
{
<input type="text" id="mealsOverallCost" readonly="readonly"
value="@ViewBag.OverallCost" />
<input type="hidden" name="overallCost" value="@ViewBag.OverallCost" />
<input type="submit" />
}