本文整理汇总了C#中this.AttributeEncode方法的典型用法代码示例。如果您正苦于以下问题:C# this.AttributeEncode方法的具体用法?C# this.AttributeEncode怎么用?C# this.AttributeEncode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类this
的用法示例。
在下文中一共展示了this.AttributeEncode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FormPostLink
/// <summary>
/// Returns a form with a delete button, plus a hidden anchor we can display via Ajax to make a delete link that does a post.
/// </summary>
public static HtmlString FormPostLink(this HtmlHelper helper, string linkText, string actionName, string controllerName, object routeValues)
{
var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
string url = urlHelper.Action(actionName, controllerName, routeValues);
string format = @"<form method=""post"" action=""{0}"" class=""formPostLink""><input type=""submit"" value=""{1}"" />{2}</form>";
string form = string.Format(format, helper.AttributeEncode(url), helper.AttributeEncode(linkText), helper.AntiForgeryToken());
return new HtmlString(form + helper.ActionLink(linkText, actionName, controllerName, routeValues, new { @class = "formPostLink" }).ToString());
}
示例2: Gravatar
public static MvcHtmlString Gravatar(this HtmlHelper html, string email, string name, int size = 72)
{
var imgUrl = string.Format(
"http://www.gravatar.com/avatar/{0}.jpg?s={1}&d=mm&r=g",
HashString(email),
size);
return new MvcHtmlString("<img alt=\"" + html.AttributeEncode(name) + "\" src=\"" + html.AttributeEncode(imgUrl) + "\" />");
}
示例3: Script
public static HtmlString Script(this HtmlHelper helper, string fileName)
{
if (!fileName.EndsWith(".js"))
fileName += ".js";
var jsPath = string.Format("<script src='{0}/{1}/{2}' ></script>\n", Url.SiteUrl(pubDir), scriptDir, helper.AttributeEncode(fileName));
return new HtmlString(jsPath);
}
示例4: CSS
public static MvcHtmlString CSS(this HtmlHelper helper, string fileName, string media)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
var jsPath = string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}' media='" + media + "'/>\n", VirtualPathUtility.ToAbsolute(pubDir), cssDir, helper.AttributeEncode(fileName));
return MvcHtmlString.Create(jsPath);
}
示例5: CSS
public static string CSS(this HtmlHelper helper, string fileName, string media)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
var jsPath = string.Format("<link rel=\"stylesheet\" type=\"text/css\" href=\"{0}/{1}/{2}\" media=\"" + media + "\"/>\n", pubDir, cssDir, helper.AttributeEncode(fileName));
return jsPath;
}
示例6: CSS
public static HtmlString CSS(this HtmlHelper helper, string fileName, string media)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
var jsPath = string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}' media='" + media + "'/>\n", GetPublicUrl(helper), cssDir, helper.AttributeEncode(fileName));
return new HtmlString(jsPath);
}
示例7: Gravatar
public static MvcHtmlString Gravatar(this HtmlHelper html, string email, string name, int size = 72)
{
var fallBack = WebConfigurationManager.AppSettings["GravatarFallBack"];
if (string.IsNullOrEmpty(fallBack))
{
fallBack = "mm";
}
var imgUrl = string.Format(
"https://secure.gravatar.com/avatar/{0}.png?s={1}&d={2}&r=g",
HashString(email),
size,
fallBack);
return new MvcHtmlString("<img alt=\"\" title=\"" + html.AttributeEncode(name) + "\" src=\"" + html.AttributeEncode(imgUrl) + "\" />");
}
示例8: CSS
public static string CSS(this HtmlHelper helper, string root, string fileName, string media)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
var jsPath = string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}/{3}' media='{4}'/>\n", root, pubDir, cssDir, helper.AttributeEncode(fileName), media);
return jsPath;
}
示例9: EmbedImageExtended
public static IHtmlString EmbedImageExtended(this HtmlHelper html, string pathOrUrl, string alt = "", string height = "200px", string width = "200px")
{
if (string.IsNullOrWhiteSpace(pathOrUrl))
throw new ArgumentException(@"Path or URL required", "pathOrUrl");
if (IsFileName(pathOrUrl))
pathOrUrl = html.ViewContext.HttpContext.Server.MapPath(pathOrUrl);
return new HtmlString(string.Format("<img src=\"cid:{0}\" alt=\"{1}\"/>", (object)((ImageEmbedder)html.ViewData["Postal.ImageEmbedder"]).AddImage(pathOrUrl, (string)null).ContentId, (object)html.AttributeEncode(alt)));
}
示例10: ActionLinkWithImage
public static HtmlString ActionLinkWithImage(this HtmlHelper html, string imgName)
{
var imgUrl = string.Format("{0}/{1}/{2}"
, ContentDir
, ImageDir
, html.AttributeEncode(imgName));
return ActionLinkWithImage(imgUrl, "/");
}
示例11: FullCss
public static string FullCss(this HtmlHelper helper, string basePath, string fileName)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
basePath = VirtualPathUtility.ToAbsolute("~/") + basePath;
basePath = basePath + "public";
var jsPath = string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}'/>", basePath, cssDirectory, helper.AttributeEncode(fileName));
return jsPath;
}
示例12: EmbedImage
/// <summary>
/// Embeds the given image into the email and returns an HTML <img> tag referencing the image.
/// </summary>
/// <param name="html">The <see cref="HtmlHelper"/>.</param>
/// <param name="imagePathOrUrl">An image file path or URL. A file path can be relative to the web application root directory.</param>
/// <param name="alt">The content for the <img alt> attribute.</param>
/// <returns>An HTML <img> tag.</returns>
public static IHtmlString EmbedImage(this HtmlHelper html, string imagePathOrUrl, string alt = "")
{
if (string.IsNullOrWhiteSpace(imagePathOrUrl)) throw new ArgumentException("Path or URL required", "imagePathOrUrl");
if (IsFileName(imagePathOrUrl))
{
imagePathOrUrl = html.ViewContext.HttpContext.Server.MapPath(imagePathOrUrl);
}
var imageEmbedder = (ImageEmbedder)html.ViewData["Postal.ImageEmbedder"];
var resource = imageEmbedder.ReferenceImage(imagePathOrUrl);
return new HtmlString(string.Format("<img src=\"cid:{0}\" alt=\"{1}\"/>", resource.ContentId, html.AttributeEncode(alt)));
}
示例13: HighlightLink
public static string HighlightLink(this HtmlHelper helper, string url)
{
var fullUrl = url;
if (!url.Contains("://") && !url.StartsWith("mailto:"))
{
if (IsEmailUrl(url))
fullUrl = "mailto:" + url;
else
fullUrl = "http://" + url;
}
return $"<a href=\"{helper.AttributeEncode(HttpUtility.HtmlDecode(fullUrl))}\">{url}</a>";
}
示例14: Css
public static string Css(this HtmlHelper helper, string fileName, bool minify)
{
if (!fileName.EndsWith(".css"))
fileName += ".css";
if (minify) {
fileName = fileName.Insert(fileName.LastIndexOf('.'), ".min");
}
var jsPath = string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}' />", publicDirectory, cssDirectory, helper.AttributeEncode(fileName));
return jsPath;
}
示例15: Css
public static MvcHtmlString Css(this HtmlHelper helper, string fileName)
{
var builder = new TagBuilder("link");
var href = string.Format("{0}/{1}"
, CssDir
, helper.AttributeEncode(fileName));
builder.MergeAttribute("rel", "stylesheet");
builder.MergeAttribute("type", "text/css");
builder.MergeAttribute("href", href);
var output = new MvcHtmlString(builder.ToString());
return output;
}