キーと値のペア入力用の動的フォームを作成しました。一部の値にはコンマが含まれます。
using(Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "parameterForm" }))
{
<div id="inputBoxesDIV">
for(int i = 0; i < Model.GetParameters().Count; i++)
{
Html.TextBoxFor(m => m.GetParameters().ElementAt(i).Name, new { name = "name" + i, size = 20 })
Html.TextBoxFor(m => m.GetParameters().ElementAt(i).Value, new { name = "Value" + i, size = 60 })
}
</div>
}
FormCollection を使用して、次のようなペアを取得しようとしました。
[HttpPost]
public ActionResult Index(FormCollection formCollection)
{
foreach (var key in formCollection.AllKeys)
{
var value = formCollection[key];
}
foreach (var key in formCollection.Keys)
{
var value = formCollection[key.ToString()];
}
//etc...
しかし、FormCollection はカンマ区切りの文字列を使用するため、役に立ちません。
FormCollection をまだ使用できる方法はありますか、またはそれを解決する方法はありますか?