Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.TopNavigationMenu.Visible = false;
            try {
                SPA.User user    = new SPA.User(Context.User.Identity.Name);
                bool     IsAdmin = user.InRole(RoleType.Administrator.ToString());
                DataSet  ds      = new DataSet();
                if (IsAdmin)
                {
                    ds = Tab.ActiveItems(true);
                }
                else
                {
                    ds = Tab.ActiveItems(false);
                }

                DataView dv = new DataView();
                dv.Table     = ds.Tables[0];
                dv.Sort      = "DisplayIndex";
                dv.RowFilter = "ParentID = 0";
                foreach (DataRowView drv in dv)
                {
                    MenuItem menuItem = new MenuItem();
                    menuItem.Text        = drv["Name"].ToString();
                    menuItem.Value       = drv["ID"].ToString();
                    menuItem.NavigateUrl = drv["URL"].ToString();
                    this.TopNavigationMenu.Items.Add(menuItem);
                    this.TopNavigationMenu.Attributes.Add("padding-right", "15px");
                    AddChildItems(ds.Tables[0], menuItem);
                }
                this.TopNavigationMenu.Visible = true;
            } catch (Exception ex) {
                SPA.Error.WriteError(ex);
            }
        }