【发布时间】:2023-04-02 03:31:01
【问题描述】:
它是正确的模型吗?
public class NewForm
{
public string[] Field { get; set; }
public bool[] Check { get; set; }
}
对于这样的视图:
@Html.TextAreaFor(model => model.Field)
@Html.TextAreaFor(model => model.Field)
@Html.TextAreaFor(model => model.Field)
@Html.CheckBoxFor(model => model.Check)
@Html.CheckBoxFor(model => model.Check)
或者有没有更好的方法来创建同名字段? 在 Controller 中仅显示第一个值。但我需要所有的
[HttpPost]
public ActionResult Edit(NewForm model)
{
Response.Write(model.Field);
Response.Write(model.Check);
}
字段可能是不确定的数字,因为通过单击按钮 JavaScript 会添加一个具有相同名称的新字段
【问题讨论】:
-
您的预期行为是什么?
-
对于诸如“这是否正确”之类的问题,请使用codereview.stackexchange.com
标签: c# asp.net asp.net-mvc asp.net-mvc-4