本文整理汇总了C#中IHtmlHelper.Hidden方法的典型用法代码示例。如果您正苦于以下问题:C# IHtmlHelper.Hidden方法的具体用法?C# IHtmlHelper.Hidden怎么用?C# IHtmlHelper.Hidden使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IHtmlHelper
的用法示例。
在下文中一共展示了IHtmlHelper.Hidden方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HiddenInputTemplate
public static string HiddenInputTemplate(IHtmlHelper htmlHelper)
{
var viewData = htmlHelper.ViewData;
var model = viewData.Model;
string result;
if (viewData.ModelMetadata.HideSurroundingHtml)
{
result = string.Empty;
}
else
{
result = 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 += hiddenResult.ToString();
return result;
}
示例2: HiddenInputTemplate
public static IHtmlContent HiddenInputTemplate(IHtmlHelper htmlHelper)
{
var viewData = htmlHelper.ViewData;
var model = viewData.Model;
var result = new HtmlContentBuilder();
if (!viewData.ModelMetadata.HideSurroundingHtml)
{
result.AppendHtml(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.AppendHtml(hiddenResult);
return result;
}
示例3: HiddenInputTemplate
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;
}