Ejemplo n.º 1
0
        protected override void OnStart(System.IO.TextWriter writer)
        {
            // Add the outer group
            _buttonGroup = GetHelper().ButtonGroup().Component;
            if (Dropup)
            {
                _buttonGroup.AddCss(Css.Dropup);
            }
            _buttonGroup.Start(writer);

            // Add the action button if split and copy over button CSS classes
            // Also move the icon to the button (if one is present)
            // But only create the split if we actually have some text to put in it
            if (Split && !string.IsNullOrWhiteSpace(TextContent))
            {
                Button button = GetHelper().Button(TextContent).Component;
                MoveIcons(button);
                TextContent = null;
                foreach (string cssClass in CssClasses)
                {
                    button.CssClasses.Add(cssClass);
                }
                button.MergeAttributes(Attributes.Dictionary);
                Attributes.Dictionary.Clear();
                button.StartAndFinish(writer);
            }

            // Create the dropdown button, copy over CSS, add the text and caret, then render
            Button dropdown = GetHelper().Button(buttonType: ButtonType.Button).Component;

            MoveIcons(dropdown);
            dropdown.AddCss(Css.Btn, Css.BtnDefault, Css.DropdownToggle);
            dropdown.MergeAttribute("data-toggle", "dropdown");
            foreach (string cssClass in CssClasses)
            {
                dropdown.CssClasses.Add(cssClass);
            }
            dropdown.MergeAttributes(Attributes.Dictionary);
            Attributes.Dictionary.Clear();
            CssClasses.Clear();
            if (!string.IsNullOrWhiteSpace(TextContent))
            {
                dropdown.AddChild(GetHelper().Content(TextContent + " "));
            }
            else
            {
                Element element = GetHelper().Element("span").AddCss(Css.SrOnly).Component;
                element.AddChild(GetHelper().Content("Toggle Dropdown"));
                dropdown.AddChild(element);
            }
            dropdown.AddChild(GetHelper().Caret());
            TextContent = null;
            dropdown.StartAndFinish(writer);

            // Add CSS and attributes after we've copied all the user-specified stuff to the buttons
            MergeAttribute("role", "menu");
            AddCss(Css.DropdownMenu);

            base.OnStart(writer);
        }
Ejemplo n.º 2
0
        protected override void OnStart(TextWriter writer)
        {
            // Fix for justified buttons in a group (need to surround them with an extra button group)
            // See https://github.com/twbs/bootstrap/issues/12476
            ButtonGroup buttonGroup = GetComponent <ButtonGroup>(true);

            if (buttonGroup != null && buttonGroup.CssClasses.Contains(Css.BtnGroupJustified))
            {
                _buttonGroup = GetHelper().ButtonGroup().Component;
                _buttonGroup.Start(writer);
            }

            base.OnStart(writer);
        }