So I found another way to use the Html.DeleteConfirmation extension without adding a new map route just for a single delete call (as noted in the post right above this one)
From within my plugin, I just made a new 3 parameter DeleteConfirmation as noted:
publicstatic MvcHtmlString DeleteConfirmation<T>(this HtmlHelper<T> helper, string actionName, string controllerName, string buttonsSelector = null) where T : BaseNopEntityModel
First off the plugin I was developing at the time and talking about here was for nop v2.20.
So what I did was create a new HtmlExtensions.cs file inside my plugin. In that class I copied the original MvcHtmlString DeleteConfirmation<T> over, and made the following 3 changes to it.
Instead of:
public static MvcHtmlString DeleteConfirmation<T>(this HtmlHelper<T> helper, string actionName, string buttonsSelector = null) where T : BaseNopEntityModel
I have:
public static MvcHtmlString DeleteConfirmation<T>(this HtmlHelper<T> helper, string actionName, string controllerName, string buttonsSelector = null) where T : BaseNopEntityModel
Instead of:
if (String.IsNullOrEmpty(actionName)) actionName = "Delete";
I have:
if (String.IsNullOrEmpty(actionName)) actionName = "Delete"; if (String.IsNullOrEmpty(controllerName)) controllerName = helper.ViewContext.RouteData.GetRequiredString("controller");
Then I was able to call it with @Html.DeleteConfirmation("Delete", "Plugin/Dealer/Admin", "dealer-delete"), passing in the extra controller name that got it to work.
Hi Guys, As per above discussions, I rewrite my route to
I am building a plugin in 3.50. I've added a new menu item, which appends under Plugins menu item by default. var SubMenuItem = new SiteMapNode() { Title = "Manage", ControllerName = "CustomManager", ActionName = "List", Visible = true, RouteValues = new RouteValueDictionary() { { "area", null } }, }; and the routing defined is as routes.MapRoute("Plugin.Custom.Manager.List", "Plugins/CustomManager/List", new { controller = "CustomManager", action = "List", area = "Admin" }, new[] { "Nop.Plugin.Custom.Manager.Controllers" } ).DataTokens.Add("area", "Admin");
also tried routing with many ways like
routes.MapRoute("Plugin.Custom.Manager.List", "Admin/Plugins/CustomManager/List", new { controller = "CustomManager", action = "List", area = "Admin" }, new[] { "Nop.Plugin.Custom.Manager.Controllers" } ).DataTokens.Add("area", "Admin");
routes.MapRoute("Plugin.Custom.Manager.List", "Admin/Plugins/CustomManager/Admin/List", new { controller = "CustomManager", action = "List", area = "Admin" }, new[] { "Nop.Plugin.Custom.Manager.Controllers" } ).DataTokens.Add("area", "Admin");
I've created the List.cshtml under Views-> CustomManager -> List.cshtml & the controller is named as CustomManagerController.cs
I also added in List.cshtml @{ Layout = "~/Administration/Views/Shared/_AdminLayout.cshtml"; }
But still the url in the browser's generates as http://localhost:15536/CustomManager/List instead http://localhost:15536/Admin/CustomManager/List and also once I select my menu item, then some of the link items lose the Admin/ prefix like 'Clear cache', 'Restart application'
Please help me, what I've missed!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.