0
我有一個表格在partialViewMVC路由問題,需要幫助插入參數
@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在聖地亞哥
是,這很好。非常感謝你。我也必須在我的routevlaues中刪除模塊標記。無論如何,非常感謝。 – Hcabnettek 2010-12-15 00:30:23
通常你會將答案標記爲接受,如果它工作... – m0sa 2010-12-15 08:29:39
它不會讓我在當時標記爲正確的,因爲我剛剛問過這個問題。但是,您的回答是正確的,我標記爲這樣。再次感謝朋友! :) – Hcabnettek 2010-12-22 16:48:23