【发布时间】:2010-12-14 22:58:58
【问题描述】:
我在部分视图中有一个表单
@using (Html.BeginForm(null, null, new { controller = "Module", action="ModuleIndex", module="" }, FormMethod.Get, new { id = "frmMDR" }))
{
@Html.RadioButton("mdrSelector", "Maintenance", false, new { id = "rdoMaintenance" })<label for="rdoMaintenance">M</label>
@Html.RadioButton("mdrSelector", "Diagnostics", false, new { id = "rdoDiagnostics" })<label for="rdoDiagnostics">D</label>
@Html.RadioButton("mdrSelector", "Repair", false, new { id = "rdoRepair" })<label for="rdoRepair">R</label>
@Html.Hidden("hdnVehicle", null, new { id="hdnVehicle"})
}
当我选择一个单选按钮时,如何使用选定的单选按钮值填充模块参数?我正在使用 jQuery 在单选按钮更改事件上提交表单。
$(':radio').change(function () {
$('#frmMDR').submit();
});
这是我的控制器方法
public ActionResult ModuleIndex(string module)
{
switch (module)
{
case "Maintenance":
return RedirectToRoute(new { area = module, controller = "Maintenance" });
case "Diagnostics":
return RedirectToRoute(new { area = module, controller = "Diagnostics" });
case "Repair":
return RedirectToRoute(new { area = module, controller = "Repair" });
default:
return RedirectToRoute(new { area = module, controller = "Maintenance" });
}
}
最后这是我的路由配置
routes.MapRoute(
"Module", // Route name
"Module/ModuleIndex/{module}",
new { controller = "Module", action = "ModuleIndex", module = "" }
);
我做错了什么?任何提示或帮助都将受到赞赏。
亲切的问候,
~ck 在圣地亚哥
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 razor asp.net-mvc-routing partial-views