0
我不知道下面的代碼背後有什麼錯誤,我只想回到顯示應用程序的詳細信息頁面中的事件列表的主頁面當點擊取消按鈕時。現在,當我點擊細節頁面上的取消按鈕時,url爲sampleurl:2988/Event/Index,而不是sampleurl:2988/Event/330。任何幫助,這是高度讚賞。重定向回主頁面會導致錯誤
主頁網址: SAMPLEURL:2988 /事件/ 330
詳細信息頁面: SAMPLEURL:2988 /事件/ EditEventDetails/3
這裏是路由設置。
routes.MapRoute(
"Event", // Route name
"Event/{id}", // URL with parameters
new { controller = "Event", action = "Index", id = 0 } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Event", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
取消按鈕使用回到主頁面:
<input type="button" id="btnCancel" url="@Url.Action("Index", "Event", new { id = Model.EM_AID })" value="Cancel" class="button cancelbutton"/>
jQuery代碼:
$("#btnCancel").click(function() {
window().location.href = $(this).attr('url');
});
對不起,我的錯,我有一個重複的事件取消按鈕上的主要js和細節js。它正在工作。上面的方法也有效,但我更喜歡按鈕之一,而不是鏈接。非常感謝你的回答。 – user335160