示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            return;
        }

        // Handle the pre-selection
        preselectedItem = QueryHelper.GetString(QueryParameterName, "");
        if (preselectedItem.StartsWithCSafe("cms.", true))
        {
            preselectedItem = preselectedItem.Substring(4);
        }

        uniMenu.HighlightItem = preselectedItem;

        // If element name is not set, use root module element
        string elemName = ElementName;

        if (String.IsNullOrEmpty(elemName))
        {
            elemName = ModuleName.Replace(".", "");
        }

        // Get the UI elements
        DataSet ds = UIElementInfoProvider.GetChildUIElements(ModuleName, elemName);

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            FilterElements(ds);

            // Prepare the list of elements
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string            url  = ValidationHelper.GetString(dr["ElementTargetURL"], "");
                UIElementTypeEnum type = ValidationHelper.GetString(dr["ElementType"], "").ToEnum <UIElementTypeEnum>();

                Group group = new Group();
                if (url.EndsWithCSafe("ascx") && (type == UIElementTypeEnum.UserControl))
                {
                    group.ControlPath = url;
                }
                else
                {
                    group.UIElementID = ValidationHelper.GetInteger(dr["ElementID"], 0);
                }

                group.CssClass = "ContentMenuGroup";

                if (GenerateElementCssClass)
                {
                    string name = ValidationHelper.GetString(dr["ElementName"], String.Empty).Replace(".", String.Empty);
                    group.CssClass         += " ContentMenuGroup" + name;
                    group.SeparatorCssClass = "UniMenuSeparator" + name;
                }

                group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementCaption"], ""));
                if (group.Caption == String.Empty)
                {
                    group.Caption = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementDisplayName"], ""));
                }
                uniMenu.Groups.Add(group);
            }

            // Raise groups created event
            RaiseOnGroupsCreated(this, uniMenu.Groups);

            // Button created & filtered event handler
            uniMenu.OnButtonCreating += uniMenu_OnButtonCreating;
            uniMenu.OnButtonCreated  += uniMenu_OnButtonCreated;
            uniMenu.OnButtonFiltered += uniMenu_OnButtonFiltered;
        }

        // Add editing icon in development mode
        if (SystemContext.DevelopmentMode && MembershipContext.AuthenticatedUser.IsGlobalAdministrator && !DisableEditIcon)
        {
            var link = UIContextHelper.GetResourceUIElementLink(ModuleName, ElementName);
            if (!String.IsNullOrEmpty(link))
            {
                ltlAfter.Text += String.Format("<div class=\"UIElementsLink\" >{0}</div>", link);
            }
        }
    }