Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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 mvc 如何使用(Html.BeginForm())提交@并将其内容提交给控制器_Asp.net Mvc_Asp.net Mvc 4 - Fatal编程技术网

Asp.net mvc 如何使用(Html.BeginForm())提交@并将其内容提交给控制器

Asp.net mvc 如何使用(Html.BeginForm())提交@并将其内容提交给控制器,asp.net-mvc,asp.net-mvc-4,Asp.net Mvc,Asp.net Mvc 4,我试图从6个不同的文本框向控制器发送6个值。如果不使用JavaScript,我如何做到这一点 @using (Html.BeginForm("Save", "Admin")) { @Html.TextBox(ValueRegular.ToString(FORMAT), new { @name = "PriceValueRegularLunch" }) @Html.TextBox(ValueRegular1.ToString(FORMAT), new { @name = "PriceVal

我试图从6个不同的文本框向控制器发送6个值。如果不使用JavaScript,我如何做到这一点

@using (Html.BeginForm("Save", "Admin"))
    {
@Html.TextBox(ValueRegular.ToString(FORMAT), new { @name = "PriceValueRegularLunch" })
@Html.TextBox(ValueRegular1.ToString(FORMAT), new { @name = "PriceValueRegularLunch1" })
@Html.TextBox(ValueRegular2.ToString(FORMAT), new { @name = "PriceValueRegularLunch2" })

        <input type="submit" name="SaveButton" value="Save" />
}


[HttpPost]
        public ActionResult SavePrices(int PriceValueRegularLunch)
        {
            return RedirectToAction("Lunch", "Home");
        }
@使用(Html.BeginForm(“保存”、“管理”))
{
@TextBox(ValueRegular.ToString(格式),新的{@name=“PriceValueRegularLunch”})
@TextBox(ValueRegular1.ToString(格式),新的{@name=“pricevalueregularlaunch1”})
@TextBox(ValueRegular2.ToString(格式),新的{@name=“pricevalueregularlaunch2”})
}
[HttpPost]
公共行动结果保存价格(int PriceValueRegularLunch)
{
返回活动(“午餐”、“家”);
}

以下是控制器的外观:

public class AdminController : Controller
{        
    [HttpPost]
    public ActionResult SavePrices(int PriceValueRegularLunch, 
        int PriceValueRegularLunch1, 
        int PriceValueRegularLunch2, 
        int PriceValueRegularLunch3, 
        int PriceValueRegularLunch4, 
        int PriceValueRegularLunch5)
    {
        return RedirectToAction("Lunch", "Home");
    }
}
你的看法是:

@using (Html.BeginForm("SavePrices", "Admin"))
{
    @Html.TextBox("PriceValueRegularLunch")
    @Html.TextBox("PriceValueRegularLunch1")
    @Html.TextBox("PriceValueRegularLunch2")
    @Html.TextBox("PriceValueRegularLunch3")
    @Html.TextBox("PriceValueRegularLunch4")
    @Html.TextBox("PriceValueRegularLunch5")

    <input type="submit" name="SaveButton" value="Save" />
}
@使用(Html.BeginForm(“SavePrices”、“Admin”))
{
@Html.TextBox(“PriceValueRegular午餐”)
@Html.TextBox(“PriceValueRegularSunch1”)
@Html.TextBox(“pricevalueregularlaunch2”)
@Html.TextBox(“pricevalueregularlaunch3”)
@Html.TextBox(“pricevalueregularlaunch4”)
@Html.TextBox(“pricevalueregularlaunch5”)
}

也尝试使用模型。。