0

在 MVC5 互联网应用程序中,如何在请求和请求ViewModel List之间保留 a 的内容。HTTPGetHTTPPost

我已经进行了一些搜索,但不确定要搜索的确切术语。

这是我的情况:

我有一个ViewModel,其中填充了以下列表HTTPGet ActionResult

public List<string> azureBlobFullFileNames { get; set; }

在 中HTTPPost ActionResult,列表为空。

我怎样才能让列表中的值仍然填充HTTPPost ActionResult

我在@Html.AntiForgeryToken()View 代码行之后添加了以下代码:

@Html.HiddenFor(model => model.azureBlobFullFileNames)

但是,该列表在HTTPPost ActionResult.

我可以对这段代码有一些帮助吗?

提前致谢

4

1 回答 1

0

for使用循环为集合中的元素生成控件。

for(int i = 0; i < Model.azureBlobFullFileNames.Count; i++)
{
  @Html.HiddenFor(m => m.azureBlobFullFileNames[i])
}
于 2014-09-21T08:00:37.603 回答