Sll*_*lix 3 routevalues razor asp.net-mvc-3
剃刀视图:
@using (Html.BeginForm("Move", "Details", new { dict= dictionary}, FormMethod.Post)) {
//table with info and submit button
//dictionary => is a dictionary of type <Sales_Order_Collected, string>
}
Run Code Online (Sandbox Code Playgroud)
控制器动作:
[HttpPost]
public string Move(Dictionary<Sales_Order_Collected, string> dict) {
return "";
}
Run Code Online (Sandbox Code Playgroud)
有没有办法将模型字典传递给控制器?因为我的参数始终为空。
您不能通过路由值传递字典。你可以这样做:
@using (Html.BeginForm("Move", "Details", null, FormMethod.Post)) {
<input type="text" name="[0].Key" value="first key"/>
<input type="text" name="[0].Value" value="first value"/>
<input type="text" name="[1].Key" value="second key"/>
<input type="text" name="[1].Value" value="second value"/>
}
Run Code Online (Sandbox Code Playgroud)
这将发布字典。对于复杂对象的想法是一样的
| 归档时间: |
|
| 查看次数: |
4151 次 |
| 最近记录: |