Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WebMenu
- {
- public WebMenu()
- {
- this.Children = new List<WebMenu>();
- }
- [Key]
- public int MenuID { get; set; }
- public string MenuName { get; set; }
- public int ParentID { get; set; }
- public string ControllerName { get; set; }
- public string ActionName { get; set; }
- public string ExternalLink { get; set; }
- public List<WebMenu> Children { get; set; }
- }
- [Route("content/{id:int}")]
- public ActionResult Content()
- {
- int id = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"]);
- TempData["id"] = id;
- return View();
- }
- public ActionResult MenuPartial()
- {
- dbContext = new DbContext();
- List<WebMenu> Menu = new List<WebMenu>();
- if (id!=0)
- {
- int id = (int)TempData["id"];
- Menu = dbContext.WebMenu.Where(x => x.MenuID == id).ToList();
- //I can get what is clicked.
- }
- WebMenu clickedMenu=Menu.FirstOrDefault();
- WebMenu parentMenu=dbContext.WebMenu.Where(x=>x.MenuID==clickedMenu.ParentID).ToList();
- }
Add Comment
Please, Sign In to add comment