Example #1
0
            public override void OnActionExecuted(ActionExecutedContext filterContext)
            {
                DsDbContext context = new DsDbContext();
                var         menus   = context.menus.SqlQuery("select * from dbo.Menus where ParentId!=0").ToList();
                //filterContext.Controller.ViewBag.menus = menus;
                string html = "";

                foreach (var aMenu in menus)
                {
                    string subMenuHtml = "";
                    if (aMenu.ParentId == 1)
                    {
                        html += "<li class='dropdown'><a href='/" + aMenu.Controller + "/" + aMenu.Action + "'>" + aMenu.Caption;
                        foreach (var subMenu in menus)
                        {
                            if (subMenu.ParentId == aMenu.Id)
                            {
                                subMenuHtml += "<li><a href='/Content/Browse/" + subMenu.Id + "'>" + subMenu.Caption + "<a/></li>";
                            }
                        }
                        if (subMenuHtml != "")
                        {
                            html = html + "<span class='caret'></span></a><ul class='dropdown-menu'>" + subMenuHtml + "</ul>" + "</li>";
                        }
                        else
                        {
                            html = html + "</a></li>";
                        }
                    }
                }
                //IHtmlString htmlStr = new HelperResult(html);
                filterContext.Controller.ViewBag.html = html;
            }