Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 将输入文本中的值放入Html.BeginForm中的参数_Asp.net_Asp.net Mvc_Razor - Fatal编程技术网

Asp.net 将输入文本中的值放入Html.BeginForm中的参数

Asp.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

我有Html.begin

@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" />
}