public static void BooleanTemplate(HtmlHelper html, IXcstPackage package, ISequenceWriter <object> seqOutput) { ViewDataDictionary viewData = html.ViewData; bool?value = null; if (viewData.Model != null) { value = Convert.ToBoolean(viewData.Model, CultureInfo.InvariantCulture); } if (viewData.ModelMetadata.IsNullableValueType) { XcstWriter output = DocumentWriter.CastElement(package, seqOutput); string?className = GetEditorCssClass(new EditorInfo("Boolean", "select"), "list-box tri-state"); var htmlAttributes = CreateHtmlAttributes(html, className); SelectInstructions.Select(html, output, String.Empty, TriStateValues(value), htmlAttributes: htmlAttributes); } else { string?className = GetEditorCssClass(new EditorInfo("Boolean", "input", InputType.CheckBox), "check-box"); var htmlAttributes = CreateHtmlAttributes(html, className); InputInstructions.CheckBox(html, package, seqOutput, String.Empty, value.GetValueOrDefault(), htmlAttributes: htmlAttributes); } }
public static void PasswordTemplate(HtmlHelper html, IXcstPackage package, ISequenceWriter <object> seqOutput) { XcstWriter output = DocumentWriter.CastElement(package, seqOutput); string?className = GetEditorCssClass(new EditorInfo("Password", "input", InputType.Password), "text-box single-line password"); var htmlAttributes = CreateHtmlAttributes(html, className, addMetadataAttributes: true); InputInstructions.Input(html, output, String.Empty, value: null, type: "password", htmlAttributes: htmlAttributes); }
static void HtmlInputTemplateHelper(HtmlHelper html, IXcstPackage package, ISequenceWriter <object> seqOutput, string templateName, string?inputType = null) { XcstWriter output = DocumentWriter.CastElement(package, seqOutput); object value = html.ViewData.TemplateInfo.FormattedModelValue; string?className = GetEditorCssClass(new EditorInfo(templateName, "input", InputType.Text), "text-box single-line"); var htmlAttributes = CreateHtmlAttributes(html, className, inputType: inputType, addMetadataAttributes: true); InputInstructions.Input(html, output, name: String.Empty, value: value, htmlAttributes: htmlAttributes); }
public static void HiddenInputTemplate(HtmlHelper html, IXcstPackage package, ISequenceWriter <object> seqOutput) { ViewDataDictionary viewData = html.ViewData; if (!viewData.ModelMetadata.HideSurroundingHtml) { DefaultDisplayTemplates.StringTemplate(html, package, seqOutput); } XcstWriter output = DocumentWriter.CastElement(package, seqOutput); object?model = viewData.Model; string?className = GetEditorCssClass(new EditorInfo("HiddenInput", "input", InputType.Hidden), null); var htmlAttributes = CreateHtmlAttributes(html, className); InputInstructions.Input(html, output, String.Empty, model, type: "hidden", htmlAttributes: htmlAttributes); }