Пример #1
0
        public static string CssMenu(this HtmlHelper helper)
        {
            var sb = new StringBuilder();
            string[] userroles = new NMPRoleProvider().GetRolesForUser(HttpContext.Current.User.Identity.Name.ToString());
            var topLevelNodes = SiteMap.RootNode.ChildNodes;

            try
            {
                sb.Append("<ul class=\"cssMenu cssMenum0\">");

                LoopBranch(topLevelNodes, ref sb, ref helper, false, userroles);

                sb.Append("</ul>");
            }
            catch
            {
                //Do nothing
            }

            return sb.ToString();
        }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Literal myLiteral = (Literal)this.FindControl("ltlMenu");
        myLiteral.Text = "Hi";

        var sb = new StringBuilder();
        string[] userroles = new NMPRoleProvider().GetRolesForUser(HttpContext.Current.User.Identity.Name.ToString());
        var topLevelNodes = SiteMap.RootNode.ChildNodes;

        try
        {
            sb.Append("<ul class=\"cssMenu cssMenum0\">");

            LoopBranch(topLevelNodes, ref sb,  false, userroles);

            sb.Append("</ul>");
        }
        catch
        {
            //Do nothing
        }

        myLiteral.Text = sb.ToString();
    }