コード例 #1
0
        private IHtmlString GetSingleCheckboxHtml(IReadonlyFieldConfiguration fieldConfiguration)
        {
            var attrs = new HtmlAttributes(fieldConfiguration.HtmlAttributes);

            AdjustHtmlForModelState(attrs, FieldGenerator);
            var fieldhtml = HtmlCreator.BuildSingleCheckbox(GetFieldName(FieldGenerator), GetValue() ?? false, attrs);

            if (fieldConfiguration.HasInlineLabel)
            {
                if (fieldConfiguration.ShouldInlineLabelWrapElement)
                {
                    var inlineLabelText = fieldConfiguration.InlineLabelText;

                    var content = fieldhtml.ToHtmlString() + " " + (inlineLabelText != null ? inlineLabelText.ToHtmlString() : FieldGenerator.GetFieldDisplayName());

                    return(HtmlCreator.BuildLabel(null, new HtmlString(content), null));
                }
                else
                {
                    return(new HtmlString(string.Format("{0} {1}", fieldhtml, HtmlCreator.BuildLabel(
                                                            GetFieldName(FieldGenerator),
                                                            fieldConfiguration.InlineLabelText ?? FieldGenerator.GetFieldDisplayName().ToHtml(),
                                                            null
                                                            ))));
                }
            }
            else
            {
                return(fieldhtml);
            }
        }
コード例 #2
0
        private IHtmlString GetSingleCheckboxHtml(IReadonlyFieldConfiguration fieldConfiguration)
        {
            var attrs = new HtmlAttributes(fieldConfiguration.HtmlAttributes);

            AdjustHtmlForModelState(attrs, FieldGenerator);
            var fieldhtml = HtmlCreator.BuildSingleCheckbox(GetFieldName(FieldGenerator), GetValue() ?? false, attrs);
            var labelHtml = HtmlCreator.BuildLabel(
                GetFieldName(FieldGenerator),
                fieldConfiguration.InlineLabelText ?? FieldGenerator.GetFieldDisplayName().ToHtml(),
                null
                );

            return(new HtmlString(string.Format("{0} {1}", fieldhtml, labelHtml)));
        }
コード例 #3
0
        private Nancy.ViewEngines.Razor.IHtmlString GetSingleCheckboxHtml()
        {
            var attrs = new HtmlAttributes(FieldConfiguration.HtmlAttributes);

            AdjustHtmlForModelState(attrs);
            var fieldhtml = HtmlCreator.BuildSingleCheckbox(GetFieldName(), GetValue() ?? false, attrs);
            var labelHtml = HtmlCreator.BuildLabel(
                GetFieldName(),
                FieldConfiguration.InlineLabelText ?? new NonEncodedHtmlString(FieldGenerator.GetFieldDisplayName()),
                null
                );

            return(new NonEncodedHtmlString(string.Format("{0} {1}", fieldhtml, labelHtml)));
        }
コード例 #4
0
        private IHtmlContent GetSingleCheckboxHtml(IReadonlyFieldConfiguration fieldConfiguration)
        {
            var attrs = new HtmlAttributes(fieldConfiguration.HtmlAttributes);

            AdjustHtmlForModelState(attrs);
            var fieldHtml = HtmlCreator.BuildSingleCheckbox(GetFieldName(), GetValue() ?? false, attrs);

            if (fieldConfiguration.HasInlineLabel)
            {
                if (fieldConfiguration.ShouldInlineLabelWrapElement)
                {
                    var inlineLabelText = fieldConfiguration.InlineLabelText;

                    var contentBuilder = new HtmlContentBuilder();
                    contentBuilder.AppendHtml(fieldHtml);
                    contentBuilder.Append(" ");
                    if (inlineLabelText != null)
                    {
                        contentBuilder.AppendHtml(inlineLabelText);
                    }
                    else
                    {
                        contentBuilder.Append(FieldGenerator.GetFieldDisplayName());
                    }

                    return(HtmlCreator.BuildLabel(null, contentBuilder, null));
                }
                else
                {
                    return(new HtmlContentBuilder()
                           .AppendHtml(fieldHtml)
                           .Append(" ")
                           .AppendHtml(HtmlCreator.BuildLabel(GetFieldName(), fieldConfiguration.InlineLabelText ?? FieldGenerator.GetFieldDisplayName().ToHtml(), null)));
                }
            }
            else
            {
                return(fieldHtml);
            }
        }