Example #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            List <Control> iconAndTextControls = new List <Control>();

            if (this.Icon != null && this.IconPosition == Position.Left)
            {
                iconAndTextControls.Add(Icon);
            }

            iconAndTextControls.Add(new LiteralControl(this.Text));

            if (this.Icon != null && this.IconPosition == Position.Right)
            {
                iconAndTextControls.Add(Icon);
            }

            string onClick = "";

            if (Page != null)
            {
                if (CausesValidation || ValidationGroup.IsSet())
                {
                    PostBackOptions options = new PostBackOptions(this);
                    options.ValidationGroup   = this.ValidationGroup;
                    options.PerformValidation = true;
                    onClick = Page.ClientScript.GetPostBackEventReference(options, true);
                }
                else
                {
                    onClick = Page.ClientScript.GetPostBackClientHyperlink(this, "");
                }
            }

            writer.WriteHtmlElement(new HtmlElement(
                                        type: Type,
                                        attributes: new HtmlAttribute[] {
                new HtmlClassAttribute(CssClass, Size.ToRender(), CssStyle.ToRender()),
                new HtmlTypeAttribute("submit"),
                new HtmlNameAttribute(this.UniqueID),
                new HtmlAttribute("disabled", "disabled", !IsEnabled),
                new HtmlAttribute("data-toggle", "button", IsToggleable),
                new HtmlAttribute("onclick", onClick, !UseSubmitBehavior)
            },
                                        controls: iconAndTextControls.ToArray()
                                        ));
        }
Example #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            this.EnsureChildControls();

            Control[] headerCtrls = new Control[this.HeaderControls.Controls.Count];
            this.HeaderControls.Controls.CopyTo(headerCtrls, 0);

            Control[] bodyCtrls = new Control[this.BodyControls.Controls.Count];
            this.BodyControls.Controls.CopyTo(bodyCtrls, 0);

            Control[] footerCtrls = new Control[this.FooterControls.Controls.Count];
            this.FooterControls.Controls.CopyTo(footerCtrls, 0);

            writer.WriteHtmlElement(new HtmlElement(
                                        attributes: new HtmlAttribute[] {
                new HtmlClassAttribute("panel", CssStyle.ToRender(), CssClass)
            },
                                        elements: new HtmlElement[] {
                new HtmlElement(
                    attributes: new HtmlAttribute[] {
                    new HtmlClassAttribute("panel-heading")
                },
                    controls: headerCtrls
                    ),
                new HtmlElement(
                    attributes: new HtmlAttribute[] {
                    new HtmlClassAttribute("panel-body")
                },
                    controls: bodyCtrls
                    ),
                new HtmlElement(
                    isRendered: this.ShowFooter,
                    attributes: new HtmlAttribute[] {
                    new HtmlClassAttribute("panel-footer")
                },
                    controls: footerCtrls
                    ),
            }
                                        ));
        }
        protected override void Render(HtmlTextWriter writer)
        {
            HtmlClassAttribute titleClass =
                HasSeparatedArrow ?
                new HtmlClassAttribute("btn", CssStyle.ToRender(), Size.ToRender()):
                new HtmlClassAttribute("btn", CssStyle.ToRender(), Size.ToRender(), "dropdown-toggle");

            writer.WriteHtmlElement(new HtmlElement(
                                        attributes: new HtmlAttribute[] {
                new HtmlClassAttribute("btn-group", Direction.ToRender())
            },
                                        elements: new HtmlElement[] {
                new HtmlElement(
                    type: HtmlTextWriterTag.Button,
                    attributes: new HtmlAttribute[] {
                    new HtmlTypeAttribute("button"),
                    titleClass,
                    new HtmlAttribute("data-toggle", "dropdown", !HasSeparatedArrow)
                },
                    content: this.Text,
                    elements: new HtmlElement[] {
                    new HtmlCaretElement(!HasSeparatedArrow)
                }
                    ),
                new HtmlElement(
                    isRendered: HasSeparatedArrow,
                    type: HtmlTextWriterTag.Button,
                    attributes: new HtmlAttribute[] {
                    new HtmlTypeAttribute("button"),
                    new HtmlClassAttribute("btn", CssStyle.ToRender(), "dropdown-toggle"),
                    new HtmlAttribute("data-toggle", "dropdown")
                },
                    content: CARET
                    )
            },
                                        controls: new Control[] {
                Menu
            }
                                        ));
        }
Example #4
0
        protected override void Render(HtmlTextWriter writer)
        {
            this.EnsureChildControls();

            Control[] leftCtrls = new Control[this.LeftControls.Controls.Count];
            this.LeftControls.Controls.CopyTo(leftCtrls, 0);

            Control[] rightCtrls = new Control[this.RightControls.Controls.Count];
            this.RightControls.Controls.CopyTo(rightCtrls, 0);

            writer.WriteHtmlElement(new HtmlElement(
                                        name: "nav",
                                        attributes: new HtmlAttribute[] {
                new HtmlClassAttribute("navbar", CssStyle.ToRender(), Position.ToRender()),
                new HtmlAttribute("role", "navigation")
            },
                                        elements: new HtmlElement[] {
                new HtmlElement(
                    attributes: new HtmlAttribute[] {
                    new HtmlClassAttribute("navbar-header")
                },
                    elements: new HtmlElement[] {
                    new HtmlElement(
                        type: HtmlTextWriterTag.A,
                        attributes: new HtmlAttribute[] {
                        new HtmlClassAttribute("navbar-brand"),
                        new HtmlHrefAttribute(this.BrandNavigateUrl),
                    },
                        content: this.BrandText
                        )
                }
                    ),
                new HtmlElement(
                    attributes: new HtmlAttribute[] {
                    new HtmlClassAttribute("collapse", "navbar-collapse", "navbar-ex1-collapse")
                },
                    elements: new HtmlElement[] {
                    new HtmlElement(
                        type: HtmlTextWriterTag.Ul,
                        attributes: new HtmlAttribute[] {
                        new HtmlClassAttribute("nav", "navbar-nav")
                    },
                        controls: leftCtrls
                        ),
                    new HtmlElement(
                        isRendered: this.ShowSearch,
                        attributes: new HtmlAttribute[] {
                        new HtmlClassAttribute("navbar-form", this.SearchBarPosition == Bootstrap.NET.Position.Left ? "navbar-left" : "navbar-right"),
                        new HtmlAttribute("role", "search")
                    },
                        controls: new Control[] {
                        searchInput,
                        searchButton
                    }
                        ),
                    new HtmlElement(
                        type: HtmlTextWriterTag.Ul,
                        attributes: new HtmlAttribute[] {
                        new HtmlClassAttribute("nav", "navbar-nav", "navbar-right")
                    },
                        controls: rightCtrls
                        )
                }
                    )
            }
                                        ));
        }