本文整理汇总了C#中HtmlHelper.Encode方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.Encode方法的具体用法?C# HtmlHelper.Encode怎么用?C# HtmlHelper.Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper.Encode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UrlTemplate
internal static string UrlTemplate(HtmlHelper html)
{
return String.Format(CultureInfo.InvariantCulture,
"<a href=\"{0}\">{1}</a>",
html.AttributeEncode(html.ViewContext.ViewData.Model),
html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue));
}
示例2: ObjectTemplate
internal static string ObjectTemplate(HtmlHelper html, TemplateHelpers.TemplateHelperDelegate templateHelper)
{
ViewDataDictionary viewData = html.ViewContext.ViewData;
TemplateInfo templateInfo = viewData.TemplateInfo;
ModelMetadata modelMetadata = viewData.ModelMetadata;
StringBuilder builder = new StringBuilder();
if (templateInfo.TemplateDepth > 1)
{
if (modelMetadata.Model == null)
{
return modelMetadata.NullDisplayText;
}
// DDB #224751
string text = modelMetadata.SimpleDisplayText;
if (modelMetadata.HtmlEncode)
{
text = html.Encode(text);
}
return text;
}
foreach (ModelMetadata propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo)))
{
if (!propertyMetadata.HideSurroundingHtml)
{
string label = LabelExtensions.LabelHelper(html, propertyMetadata, propertyMetadata.PropertyName).ToHtmlString();
if (!String.IsNullOrEmpty(label))
{
builder.AppendFormat(CultureInfo.InvariantCulture, "<div class=\"editor-label\">{0}</div>\r\n", label);
}
builder.Append("<div class=\"editor-field\">");
}
builder.Append(templateHelper(html, propertyMetadata, propertyMetadata.PropertyName, null /* templateName */, DataBoundControlMode.Edit, null /* additionalViewData */));
if (!propertyMetadata.HideSurroundingHtml)
{
builder.Append(" ");
builder.Append(html.ValidationMessage(propertyMetadata.PropertyName));
builder.Append("</div>\r\n");
}
}
return builder.ToString();
}
示例3: StringTemplate
internal static string StringTemplate(HtmlHelper html)
{
return html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue);
}
示例4: UrlTemplate
internal static string UrlTemplate(HtmlHelper html, object attributes = null)
{
var dataAttributes = html.ViewContext.ViewData.ModelMetadata.AdditionalValues.GetDataAttributes();
var customAttributes = html.ViewContext.ViewData.ModelMetadata.AdditionalValues.GetCustomAttributes();
dataAttributes.MergeAttributes(customAttributes);
TagBuilder mailTo = new TagBuilder("a");
mailTo.MergeAttribute("href", html.AttributeEncode(html.ViewContext.ViewData.Model));
mailTo.MergeAttributes(dataAttributes);
mailTo.InnerHtml = html.Encode(html.ViewContext.ViewData.TemplateInfo.FormattedModelValue);
return mailTo.ToString(TagRenderMode.Normal);
}