Esempio n. 1
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            for (int i = 0; i < this._menuItems.Count; i++)
            {
                DynamicMenuItem item = this._menuItems[i];

                DynamicMenuPopoutItem ctrl = new DynamicMenuPopoutItem(item, this._itemStyle, this._aciveItemStyle, this._hoverItemStyle);
                ctrl.SelectorMode       = this._selectorMode;
                ctrl.ParentGroup        = this;
                ctrl.MenuItemClicked   += new DynamicMenuEventHandler(ctrl_MenuItemClicked);
                ctrl.MenuItemRendering += new DynamicMenuItemRenderingEventHandler(ctrl_MenuItemRendering);
                this.Controls.Add(ctrl);

                if (item.MenuItems.Count > 0)
                {
                    DynamicMenuPopoutGroup ctrlGrp = new DynamicMenuPopoutGroup(item.MenuItems, this._itemStyle, this._aciveItemStyle, this._hoverItemStyle);
                    ctrlGrp.SelectorMode       = this._selectorMode;
                    ctrlGrp._isSubMenu         = true;
                    ctrlGrp.MenuItemClicked   += new DynamicMenuEventHandler(ctrl_MenuItemClicked);
                    ctrlGrp.MenuItemRendering += new DynamicMenuItemRenderingEventHandler(ctrl_MenuItemRendering);
                    this.Controls.Add(ctrlGrp);
                    this._assocDivs.Add(ctrlGrp.ClientID, item.MenuItemProviderKey.ToString());
                }

                this.Controls.Add(ctrl);
            }
        }
Esempio n. 2
0
        //***************************************************************************
        // Private Methods
        //
        protected override void Render(HtmlTextWriter writer)
        {
            base.Render(writer);

            if (!this.CheckRender())
            {
                return;
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, string.IsNullOrEmpty(this.CssClass) ? (this._isSubMenu ? "popoutSubMenu" : "popoutMenu") : this.CssClass);
            if (this._isSubMenu && !this._expanded)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            StringBuilder jsInit = new StringBuilder();

            for (int i = 0; i < this.Controls.Count; i++)
            {
                DynamicMenuPopoutItem ctrl = (this.Controls[i] as DynamicMenuPopoutItem);
                if (ctrl != null)
                {
                    if (ctrl.MenuItem.MenuItems.Count > 0)
                    {
                        // Setup the javascript event handler for the menu items that have popout menus.
                        jsInit.AppendLine(string.Format("dynamicMenuControl_SetupPopupMenus('{0}','{1}', '{2}');", ctrl.ClientID, this._assocDivs[ctrl.MenuItem.MenuItemProviderKey.ToString()], ctrl.MenuItem.MenuItemProviderKey));
                    }

                    // I have modified the javascript to use jQuery to 'capture' any navigation menu items and read their child anchor's href.
                    //else if (!string.IsNullOrEmpty(ctrl.MenuItem.NavigationUrl))
                    //    // Setup javascript event handlers for the menu items that are just navigation links so that the containing 'span' will also trigger navigation.
                    //    jsInit.AppendLine(string.Format("dynamicMenuControl_SetupPopupMenuNav('{0}', '{1}');", ctrl.ClientID, ctrl.MenuItem.NavigationUrl));

                    ctrl.RenderControl(writer);
                }
            }
            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), this.JavascriptKeyName, jsInit.ToString(), true);

            writer.RenderEndTag();

            for (int i = 0; i < this.Controls.Count; i++)
            {
                if (this.Controls[i] is DynamicMenuPopoutGroup)
                {
                    this.Controls[i].RenderControl(writer);
                }
            }
        }
Esempio n. 3
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            for (int i = 0; i < this._menuItems.Count; i++)
            {
                DynamicMenuItem item = this._menuItems[i];

                DynamicMenuPopoutItem ctrl = new DynamicMenuPopoutItem(item, this._itemStyle, this._aciveItemStyle, this._hoverItemStyle);
                ctrl.SelectorMode = this._selectorMode;
                ctrl.ParentGroup = this;
                ctrl.MenuItemClicked += new DynamicMenuEventHandler(ctrl_MenuItemClicked);
                ctrl.MenuItemRendering += new DynamicMenuItemRenderingEventHandler(ctrl_MenuItemRendering);
                this.Controls.Add(ctrl);

                if (item.MenuItems.Count > 0)
                {
                    DynamicMenuPopoutGroup ctrlGrp = new DynamicMenuPopoutGroup(item.MenuItems, this._itemStyle, this._aciveItemStyle, this._hoverItemStyle);
                    ctrlGrp.SelectorMode = this._selectorMode;
                    ctrlGrp._isSubMenu = true;
                    ctrlGrp.MenuItemClicked += new DynamicMenuEventHandler(ctrl_MenuItemClicked);
                    ctrlGrp.MenuItemRendering += new DynamicMenuItemRenderingEventHandler(ctrl_MenuItemRendering);
                    this.Controls.Add(ctrlGrp);
                    this._assocDivs.Add(ctrlGrp.ClientID, item.MenuItemProviderKey.ToString());
                }

                this.Controls.Add(ctrl);
            }
        }