@using (Html.BeginForm("testingMethod","test",FormMethod.Get)) {
@Html.AntiForgeryToken()
@foreach (var item in Model) {
@Html.DropDownList("dropDown_"+item.ConfigCode+"_ListName", (IEnumerable<SelectListItem>)ViewData["dropDown_"+item.ConfigCode])
}
.
.
.
.
}
<input type="submit" value="Save" />
上記のコードに基づいて、「testController」で URL を返すメソッド「testingMethod」を正常に呼び出します。
http://localhost:59512/test/testing?__RequestVerificationToken=xxxxxxx&dropDown_KKK=3
私の ActionResult "testingMethod" で、この dropDown_KKK 値 3 を取得する必要があります。メソッドで何をすればよいでしょうか? 以下のようにtestingMethodを編集してみました:
public ActionResult testing(FormCollection collection){
Debug.WriteLine(" ======= " + collection.GET("dropDown_KKK"));
}
他の投稿に基づいて、それは動作するはずですが、System.Web.MvC.FormCollection に GET の定義が含まれておらず、最初の引数 blablabla を受け入れる拡張メソッド 'GET' がないと言う collection.GET でエラーが発生します...