当前位置: 首页>>代码示例>>C#>>正文


C# this.AttributeEncode方法代码示例

本文整理汇总了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());
 }
开发者ID:henrikrossen,项目名称:SimpleBlog,代码行数:11,代码来源:HtmlHelper.cs

示例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) + "\" />");
        }
开发者ID:cwattengard,项目名称:WebGitNet,代码行数:9,代码来源:HtmlHelpers.cs

示例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);
 }
开发者ID:robconery,项目名称:Hacking-WebMatrix,代码行数:7,代码来源:HtmlHelpers.cs

示例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);
 }
开发者ID:Tifancy,项目名称:SigmaWMS,代码行数:7,代码来源:HtmlExtensions.cs

示例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;
 }
开发者ID:ngbrown,项目名称:NewsletterSignupDemo,代码行数:7,代码来源:HtmlHelpers.cs

示例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);
 }
开发者ID:dtsagile,项目名称:dmg-signalr,代码行数:7,代码来源:HtmlHelpers.cs

示例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) + "\" />");
        }
开发者ID:GoddessArtemis,项目名称:WebGitNet,代码行数:16,代码来源:HtmlHelpers.cs

示例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;
 }
开发者ID:enriquein,项目名称:snippets,代码行数:7,代码来源:HtmlHelperExtensions.cs

示例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)));
 }
开发者ID:haithemaraissia,项目名称:RentalMVCClean,代码行数:8,代码来源:PostalExtenedHelper.cs

示例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, "/");
        }
开发者ID:Ordojan,项目名称:Online-movie-store,代码行数:9,代码来源:HtmlHelpers.cs

示例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;
        }
开发者ID:jimschubert,项目名称:Richmond-Day-Helpers,代码行数:11,代码来源:HtmlHelpers.cs

示例12: EmbedImage

        /// <summary>
        /// Embeds the given image into the email and returns an HTML &lt;img&gt; 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 &lt;img alt&gt; attribute.</param>
        /// <returns>An HTML &lt;img&gt; 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)));
        }
开发者ID:CGijbels,项目名称:postal,代码行数:19,代码来源:HtmlExtensions.cs

示例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>";
		}
开发者ID:kontur-edu,项目名称:uLearn,代码行数:12,代码来源:HtmlExtensions.cs

示例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;
        }
开发者ID:jimschubert,项目名称:Richmond-Day-Helpers,代码行数:12,代码来源:HtmlHelpers.cs

示例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;
        }
开发者ID:Ordojan,项目名称:Electronix,代码行数:15,代码来源:HtmlHelpers.cs


注:本文中的this.AttributeEncode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。