public static string HiddenInputTemplate(IHtmlHelper html) { var viewData = html.ViewData; var model = viewData.Model; string result; if (viewData.ModelMetadata.HideSurroundingHtml) { result = string.Empty; } else { result = DefaultDisplayTemplates.StringTemplate(html); } // Special-case opaque values and arbitrary binary data. var modelAsByteArray = model as byte[]; if (modelAsByteArray != null) { model = Convert.ToBase64String(modelAsByteArray); } var htmlAttributesObject = viewData[HtmlAttributeKey]; var hiddenResult = html.Hidden(name: null, value: model, htmlAttributes: htmlAttributesObject); result += hiddenResult.ToString(); return(result); }
public static IHtmlContent HiddenInputTemplate(IHtmlHelper htmlHelper) { var viewData = htmlHelper.ViewData; var model = viewData.Model; var result = new BufferedHtmlContent(); if (!viewData.ModelMetadata.HideSurroundingHtml) { result.Append(DefaultDisplayTemplates.StringTemplate(htmlHelper)); } // Special-case opaque values and arbitrary binary data. var modelAsByteArray = model as byte[]; if (modelAsByteArray != null) { model = Convert.ToBase64String(modelAsByteArray); } var htmlAttributesObject = viewData[HtmlAttributeKey]; var hiddenResult = htmlHelper.Hidden(expression: null, value: model, htmlAttributes: htmlAttributesObject); result.Append(hiddenResult); return(result); }
private static IHtmlContent BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool?value) { return(htmlHelper.DropDownList( expression: null, selectList: DefaultDisplayTemplates.TriStateValues(value), optionLabel: null, htmlAttributes: CreateHtmlAttributes(htmlHelper, "list-box tri-state"))); }
private static string BooleanTemplateDropDownList(IHtmlHelper html, bool?value) { return(html.DropDownList( string.Empty, DefaultDisplayTemplates.TriStateValues(value), CreateHtmlAttributes(html, "list-box tri-state")) .ToString()); }
private static string BooleanTemplateDropDownList(IHtmlHelper html, bool?value) { return(html.DropDownList( name: null, selectList: DefaultDisplayTemplates.TriStateValues(value), optionLabel: null, htmlAttributes: CreateHtmlAttributes(html, "list-box tri-state")) .ToString()); }
public static string HiddenInputTemplate(IHtmlHelper html) { var viewData = html.ViewData; // TODO: add ModelMetadata.HideSurroundingHtml and use here (set result to string.Empty) var result = DefaultDisplayTemplates.StringTemplate(html); var model = viewData.Model; // Special-case opaque values and arbitrary binary data. var modelAsByteArray = model as byte[]; if (modelAsByteArray != null) { model = Convert.ToBase64String(modelAsByteArray); } var htmlAttributesObject = viewData[HtmlAttributeKey]; var hiddenResult = html.Hidden(string.Empty, model, htmlAttributesObject); result += hiddenResult.ToString(); return(result); }