Inheritance: DynamicPopulateExtenderControlBase
Ejemplo n.º 1
0
Archivo: Menu.cs Proyecto: t1b1c/lwas
        protected override void CreateChildControls()
        {
            base.CreateChildControls();

            labelWrapper = new Panel();
            labelWrapper.ID = "labelWrapper";
            labelWrapper.CssClass = "menu_label_wrapper";
            labelWrapper.Width = this.Width;
            labelWrapper.Height = this.Height;
            this.Controls.Add(labelWrapper);

            if (this.DisplayMode == BulletedListDisplayMode.HyperLink || !this.ActiveLabel)
            {
                label = new Label();
                label.ID = "label";
                label.CssClass = "menu_label";
                ((Label)label).Text = this.Label;
            }
            else
            {
                label = new LinkButton();
                label.ID = "label";
                label.CssClass = "menu_link";
                ((LinkButton)label).Click += (s, e) =>
                    {
                        if (!this.BubblesMilestones)
                            OnMenuClick(this.Label, this.Argument);
                        else
                            OnMenuClick(this.CommandName, this.CommandArgument);
                    };
                ((LinkButton)label).Text = this.Label;
            }
            if (null != this.LabelWidth)
                label.Width = this.LabelWidth;
            else
                label.Width = this.Width;
            if (null != this.LabelHeight)
                label.Height = this.LabelHeight;
            else
                label.Height = this.Height;
            labelWrapper.Controls.Add(label);

            commandsList.ID = "commandsList";
            commandsList.CssClass = "menu_commands";
            commandsList.Style.Add("display", "none");
            commandsList.DisplayMode = this.DisplayMode;
            if (this.DisplayMode == BulletedListDisplayMode.LinkButton)
            {
                commandsList.Click += (s, e) =>
                    {
                        ListItem item = commandsList.Items[e.Index];
                        if (null != item)
                        {
                            if (!this.BubblesMilestones)
                                OnMenuClick(item.Text, item.Value);
                            else
                                OnMenuClick(item.Value, this.CommandArgument);
                        }
                    };
            }
            this.Controls.Add(commandsList);

            dropDownExtender = new DropDownExtender();
            dropDownExtender.ID = "dropDownExtender";
            //dropDownExtender.BehaviorID = this.ID + "Behaviour";
            dropDownExtender.TargetControlID = "labelWrapper";
            dropDownExtender.DropDownControlID = "commandsList";
            dropDownExtender.Enabled = this.Enabled;
            this.Controls.Add(dropDownExtender);
            dropDownExtender.HighlightBackColor = System.Drawing.Color.Transparent;
        }