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

            if (ValueValue != null)
            {
                tb.MergeAttribute("value", ValueValue.ToString());
            }
            if (DisabledValue)
            {
                tb.MergeAttribute("disabled", "disabled");
            }

            var formGroup = context.PeekNearest<Select>();
            var controlContext = formGroup == null ? null : formGroup.ControlContextValue;
            if (controlContext != null && controlContext.Value != null && ValueValue != null && ValueValue.ToString().Equals(controlContext.Value.ToString()))
            {
                tb.MergeAttribute("selected", "selected");
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            return tb.GetEndTag();
        }
示例#2
0
 public AnyContent BeginControls(IBootstrapContext context)
 {
     this.WriteSelfStart(context.Writer, context);
     var area = context.CreateWriter<FormGroupControls, AnyContent>().WithoutLabel(LabelValue == null).BeginContent();
     area.OnDisposing(() => WriteSelfEnd(context.Writer, context));
     return area;
 }
示例#3
0
 protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
 {
     if (value == null)
     {
         return;
     }
     var block = value as IWritable;
     if (block != null)
     {
         block.WriteTo(writer, context);
         return;
     }
     var str = value as string;
     if (str != null)
     {
         if (writeWithoutEncoding)
         {
             writer.Write(str);
         }
         else
         {
             writer.Write(context.HtmlEncode(str));
         }
         return;
     }
     writer.Write(value);
 }
示例#4
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var li = context.CreateTagBuilder("li");

            if (DisabledValue)
            {
                li.AddCssClass("disabled");
            }
            else
            {
                if (ActiveValue)
                {
                    li.AddCssClass("active");
                }
            }

            li.WriteStartTag(writer);

            var link = context.CreateTagBuilder(DisabledValue ? "span" : "a");
            if (!DisabledValue)
            {
                link.MergeAttribute("href", HrefValue);
            }

            link.WriteStartTag(writer);

            return link.GetEndTag() + li.GetEndTag();
        }
示例#5
0
        protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var formGroup = context.PeekNearest<FormGroup>();
            if (formGroup != null && ControlContextValue == null)
            {
                ControlContextValue = formGroup.ControlContextValue;
            }

            ITagBuilder div = null;
            if (!InlineValue)
            {
                div = context.CreateTagBuilder("div");
                div.AddCssClass("checkbox");
                div.WriteStartTag(writer);
            }

            var lbl = context.CreateTagBuilder("label");
            if (InlineValue)
            {
                lbl.AddCssClass("checkbox-inline");
            }
            lbl.WriteStartTag(writer);

            var input = context.CreateTagBuilder("input");
            input.MergeAttribute("type", "checkbox");
            if (ControlContextValue != null)
            {
                input.MergeAttribute("id", ControlContextValue.Name);
                input.MergeAttribute("name", ControlContextValue.Name);
                input.MergeAttribute("value", "true");
                var controlValue = ControlContextValue.Value;
                if (controlValue != null && bool.Parse(controlValue.ToString()))
                {
                    input.MergeAttribute("checked", "checked");
                }
            }
            if (DisabledValue)
            {
                input.MergeAttribute("disabled", "disabled");
            }

            ApplyCss(input);
            ApplyAttributes(input);

            ////input.MergeAttributes(helper.HtmlHelper.GetUnobtrusiveValidationAttributes(context.ExpressionText, context.Metadata));

            input.WriteFullTag(writer);

            writer.Write(" "); // writing space to separate text from checkbox itself

            writer.Write(context.HtmlEncode(TextValue));

            lbl.WriteEndTag(writer);

            if (div != null)
            {
                div.WriteEndTag(writer);
            }
        }
        protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("li");
            tb.AddCssClass("divider");
            tb.MergeAttribute("role", "presentation");

            tb.WriteFullTag(writer);
        }
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("li");
            tb.AddCssClass("dropdown-header");
            tb.MergeAttribute("role", "presentation");

            tb.WriteStartTag(writer);

            return tb.GetEndTag();
        }
        protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
        {
            if (CurrentPageValue < 1)
            {
                throw new ArgumentOutOfRangeException("CurrentPage must be 1 or greater");
            }
            if (TotalPagesValue < 1)
            {
                throw new ArgumentOutOfRangeException("TotalPages must be 1 or greater");
            }
            if (CurrentPageValue > TotalPagesValue)
            {
                throw new ArgumentOutOfRangeException(string.Format("CurrentPage ({0}) must be less or equal to TotalPages ({1})", CurrentPageValue, TotalPagesValue));
            }

            var pageStart = (PageButtonsCountBackValue == -1) ? 1 : Math.Max(1, CurrentPageValue - PageButtonsCountBackValue);
            var pageEnd = (PageButtonsCountForwardValue == -1) ? TotalPagesValue : Math.Min(TotalPagesValue, CurrentPageValue + PageButtonsCountForwardValue);

            using (Paginator.BeginContent(writer, context))
            {
                if (!HidePreviousNextButtonsValue)
                {
                    var p = Math.Max(1, CurrentPageValue - 1);
                    var pi = new PaginatorItem()
                    {
                        DisabledValue = (p == CurrentPageValue),
                        HrefValue = string.Format(HrefTemplateValue, p)
                    };
                    pi.AddContent(ButtonPreviousTextValue);
                    pi.WriteTo(writer, context);
                }
                for (var i = pageStart; i <= pageEnd; i++)
                {
                    var pi = new PaginatorItem()
                    {
                        ActiveValue = (i == CurrentPageValue),
                        HrefValue = string.Format(HrefTemplateValue, i)
                    };
                    pi.AddContent(string.Format(ButtonPageTextTemplateValue, i));
                    pi.WriteTo(writer, context);
                }
                if (!HidePreviousNextButtonsValue)
                {
                    var p = Math.Min(TotalPagesValue, CurrentPageValue + 1);
                    var pi = new PaginatorItem()
                    {
                        DisabledValue = (p == CurrentPageValue),
                        HrefValue = string.Format(HrefTemplateValue, p)
                    };
                    pi.AddContent(ButtonNextTextValue);
                    pi.WriteTo(writer, context);
                }
            }
        }
示例#9
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder(TagName);

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            return tb.GetEndTag();
        }
示例#10
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("div");
            tb.AddCssClass("panel-heading");

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            return tb.GetEndTag();
        }
示例#11
0
 public void WriteTo(TextWriter writer, IBootstrapContext context)
 {
     WriteSelf(writer, context);
     if (WriteWhitespaceSuffix)
     {
         writer.Write(" ");
     }
     if (next != null)
     {
         next.WriteTo(writer, context);
     }
 }
示例#12
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("div");
            tb.AddCssClass(SizeValue.ToCssClass());
            tb.AddCssClass(OffsetValue.ToOffsetCssClass());

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            return tb.GetEndTag();
        }
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("li");
            tb.MergeAttribute("role", "presentation");
            if (DisabledValue)
            {
                tb.AddCssClass("disabled");
            }

            tb.WriteStartTag(writer);

            var a = context.CreateTagBuilder("a");
            a.MergeAttribute("role", "menuitem");
            a.MergeAttribute("tabindex", "-1");
            a.MergeAttribute("href", DisabledValue ? "#" : HrefValue);

            a.WriteStartTag(writer);

            return "</a></li>";
        }
示例#14
0
        protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("i");
            tb.AddCssClass(TypeValue.ToCssClass());

            ApplyCss(tb);
            ApplyAttributes(tb);

            if (!NoSpacingValue)
            {
                writer.Write(" ");
            }

            tb.WriteFullTag(writer);

            if (!NoSpacingValue)
            {
                writer.Write(" ");
            }
        }
示例#15
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var tb = context.CreateTagBuilder("fieldset");

            if (DisabledValue)
            {
                tb.MergeAttribute("disabled", "disabled");
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

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

            return "</fieldset>";
        }
示例#16
0
        protected override string WriteSelfStartTag(System.IO.TextWriter writer, IBootstrapContext context)
        {
            var bg = context.PeekNearest<ButtonGroup>();
            if (bg == null)
            {
                WriteWhitespaceSuffix = true;
            }
            else
            {
                SizeValue = bg.SizeValue;
            }

            var withHref = !string.IsNullOrEmpty(HrefValue);
            var tb = context.CreateTagBuilder(withHref ? "a" : "button");

            tb.AddCssClass(TypeValue.ToCssClass());
            tb.AddCssClass(SizeValue.ToButtonCssClass());

            if (DisabledValue)
            {
                tb.AddCssClass("disabled");
            }
            if (BlockSizeValue)
            {
                tb.AddCssClass("btn-block");
            }
            if (withHref)
            {
                tb.MergeAttribute("href", HrefValue);
            }

            ApplyCss(tb);
            ApplyAttributes(tb);

            tb.WriteStartTag(writer);

            return withHref ? "</a>" : "</button>";
        }
 private static IWriter2<SelectOption, AnyContent> SelectListItemToSelectOption(IBootstrapContext context, SelectListItem item)
 {
     return context.CreateWriter<SelectOption, AnyContent>().Value(item.Value).Disabled(item.Disabled).Content(item.Text);
 }
 public TableSectionContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#19
0
 public TableRowContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#20
0
 public BootstrapHelper(IBootstrapContext context)
 {
     this.Context = context;
 }
 public ButtonToolbarContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#22
0
 public GridRowContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#23
0
 protected override void WriteSelf(System.IO.TextWriter writer, IBootstrapContext context)
 {
     writer.Write(string.Empty);
 }
 public DefinitionListContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#25
0
 public FormContentBase(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#26
0
 public SelectContent(IBootstrapContext context)
     : base(context)
 {
     // Nothing
 }
 public DummyDisposableContent(IBootstrapContext context)
 {
     // Nothing
 }
示例#28
0
 public ListContent(IBootstrapContext context)
 {
     this.Context = context;
 }
示例#29
0
 protected override AnyContent CreateContentContext(IBootstrapContext context)
 {
     return new AnyContent(context);
 }
 public SelectOptGroupContent(IBootstrapContext context)
 {
     this.Context = context;
 }