示例#1
0
        protected override void WriteSelfStart(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("div");

            tb.AddCssClass("btn-group");
            tb.AddCssClass(SizeValue.ToButtonGroupCssClass());
            if (VerticalValue)
            {
                tb.AddCssClass("btn-group-vertical");
            }
            if (JustifiedValue)
            {
                tb.AddCssClass("btn-group-justified");
            }
            if (DropUpValue)
            {
                tb.AddCssClass("dropup");
            }
            tb.MergeAttribute("role", "group");

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            context.Push(this);

            if (content != null)
            {
                content.WriteTo(writer, context);
            }
        }
示例#2
0
        protected override void WriteSelfStart(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("form");

            if (TypeValue != FormType.DefaultNone)
            {
                tb.AddCssClass(TypeValue.ToCssClass());
            }
            if (MethodValue != SubmitMethod.Get)
            {
                tb.MergeAttribute("method", MethodValue.ToString().ToLowerInvariant());
            }
            if (EnctypeValue != FormEnctype.NoValue)
            {
                tb.MergeAttribute("enctype", EnctypeValue.ToEnctype());
            }
            if (!string.IsNullOrEmpty(HrefValue))
            {
                tb.MergeAttribute("action", HrefValue);
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            context.Push(this);
        }
示例#3
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var form = context.PeekNearest <IFormContext>();
            var tb   = context.CreateTagBuilder("div");

            tb.AddCssClass("form-group");
            if (ControlContextValue != null)
            {
                if (ControlContextValue.HasErrors)
                {
                    tb.AddCssClass("has-error");
                }
                else if (ControlContextValue.HasWarning)
                {
                    tb.AddCssClass("has-warning");
                }
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            context.Push(this);

            if (LabelValue != null)
            {
                LabelValue.WriteTo(writer, context);
            }

            if (ControlValue != null)
            {
                using (context.CreateWriter <FormGroupControls, AnyContent>().WithoutLabel(LabelValue == null).BeginContent(writer))
                {
                    ControlValue.WriteTo(writer, context);
                }
            }

            if (form != null && form.TypeValue == FormType.Inline)
            {
                return("</div> "); // trailing space is important for inline forms! Bootstrap does not provide spacing between groups in css!
            }

            return("</div>");
        }
示例#4
0
        protected override void WriteSelfStart(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var form      = context.PeekNearest <IFormContext>();
            var formGroup = context.PeekNearest <FormGroup>();

            if (ControlContextValue == null)
            {
                ControlContextValue = formGroup.ControlContextValue;
            }

            ITagBuilder div = null;

            if (!SizeValue.IsEmpty())
            {
                // Inline forms does not support sized controls (we need 'some other' sizing rules?)
                if (form != null && form.TypeValue != FormType.Inline)
                {
                    if (formGroup != null && formGroup.WithSizedControlValue)
                    {
                        div = context.CreateTagBuilder("div");
                        div.AddCssClass(SizeValue.ToCssClass());
                        writer.Write(div.GetStartTag());
                    }
                    else
                    {
                        throw new InvalidOperationException("Size not allowed - call WithSizedControls() on FormGroup.");
                    }
                }
            }

            object value = null;

            var tb = context.CreateTagBuilder("select");

            tb.AddCssClass("form-control");

            if (ControlContextValue != null)
            {
                tb.MergeAttribute("id", ControlContextValue.Name);
                tb.MergeAttribute("name", ControlContextValue.Name);
                if (ControlContextValue.IsRequired)
                {
                    tb.MergeAttribute("required", "required");
                }
                value = ControlContextValue.Value;
            }
            if (DisabledValue)
            {
                tb.MergeAttribute("disabled", "disabled");
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            writer.Write(tb.GetStartTag());

            context.Push(this);

            if (ItemsValue != null)
            {
                foreach (var item in ItemsValue)
                {
                    item.WriteTo(writer, context);
                }
            }

            endTag = tb.GetEndTag() + (div == null ? string.Empty : div.GetEndTag());
        }
示例#5
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var form = context.PeekNearest<IFormContext>();
            var tb = context.CreateTagBuilder("div");
            tb.AddCssClass("form-group");
            if (ControlContextValue != null)
            {
                if (ControlContextValue.HasErrors)
                {
                    tb.AddCssClass("has-error");
                }
                else if (ControlContextValue.HasWarning)
                {
                    tb.AddCssClass("has-warning");
                }
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            context.Push(this);

            if (LabelValue != null)
            {
                LabelValue.WriteTo(writer, context);
            }

            if (ControlValue != null)
            {
                using (context.CreateWriter<FormGroupControls, AnyContent>().WithoutLabel(LabelValue == null).BeginContent(writer))
                {
                    ControlValue.WriteTo(writer, context);
                }
            }

            if (form != null && form.TypeValue == FormType.Inline)
            {
                return "</div> "; // trailing space is important for inline forms! Bootstrap does not provide spacing between groups in css!
            }

            return "</div>";
        }