3
我嘗試發送一個參數與submit
按鈕後行動,以便有我的樣本:發送一個複雜的對象作爲參數傳遞給POST操作在ASP.NET MVC3
@using(Html.BeginForm(actionName: "Search", controllerName: "MyController", routeValues: new { rv = "102" })) {
...
<input type="submit" value="Search" />
}
,這是我的搜索行動:
[HttpPost]
public virtual ActionResult Search(string rv, FormCollection collection) {
...
}
所以每一件事情是罰款,直至現在,
然後我試圖發送一個複雜的物體,像Dictionary<string, string>
所以,你可以只用string
類型rv
參數Dictionary<string, string>
和發送字典,但在這種情況下,rv
值總是返回一個字典0計數?哪裏有問題?我如何發送字典來發布操作?
更新
我也嘗試這種之一,但尚未制定(平均RV鋼是0計數的字典):
@using(Html.BeginForm(actionName: "Search", controllerName: "MyController", routeValues: new { rv = Model.MyDictionary }, method: FormMethod.Post, htmlAttributes: new { @class = "FilterForm" })) {
...
}
[HttpPost]
public virtual ActionResult Search(Dictionary<string, string> rv, FormCollection collection) {
...
}
您的意思是? http://stackoverflow.com/questions/1038386/begin-form-with-overload-that-accepts-routevalues-and-htmlattributes或此:http://stackoverflow.com/questions/9028288/mvc3-html-beginform-傳遞參數as-routevaluedictionary-失敗 –
@AliRızaAdıyahşi您提到的鏈接不適合我,我更新問題 – Saeid
你想在字典中發送什麼?你的觀點如何?你想要做模型綁定? – Shyju