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


C# HtmlHelper.AttributeEncode方法代码示例

本文整理汇总了C#中System.Web.Mvc.HtmlHelper.AttributeEncode方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.AttributeEncode方法的具体用法?C# HtmlHelper.AttributeEncode怎么用?C# HtmlHelper.AttributeEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper.AttributeEncode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRegisteredLinks

        public MvcHtmlString GetRegisteredLinks(HtmlHelper html) {
            var urlHelper = new UrlHelper(html.ViewContext.RequestContext, html.RouteCollection);

            var sb = new StringBuilder();
            foreach (var feed in _feeds) {
                var linkUrl = feed.IsExternal ?
                    feed.ExternalUrl :
                    urlHelper.RouteUrl(feed.RouteValues);
                sb.Append("\r\n<link rel=\"alternate\" type=\"application/" +
                    feed.Format.ToLowerInvariant() + "+xml\"");
                if (!string.IsNullOrEmpty(feed.Title)) {
                    sb.Append(" title=\"" + html.AttributeEncode(feed.Title) + "\"");
                }
                sb.Append(" href=\"" + html.AttributeEncode(linkUrl) + "\"/>");
            }

            return MvcHtmlString.Create(sb.ToString());
        }
开发者ID:kyletowb,项目名称:InfusionDocs,代码行数:18,代码来源:FeedburnerFeedManager.cs

示例2: GetRegisteredLinks

        public MvcHtmlString GetRegisteredLinks(HtmlHelper html) {
            var urlHelper = new UrlHelper(html.ViewContext.RequestContext, html.RouteCollection);

            var sb = new StringBuilder();
            foreach (var link in _links) {
                var linkUrl = String.IsNullOrWhiteSpace(link.Url) ? urlHelper.RouteUrl(link.RouteValues) : link.Url;
                sb.Append("\r\n");
                sb.Append(@"<link rel=""alternate"" type=""application/rss+xml""");
                if (!string.IsNullOrEmpty(link.Title)) {
                    sb
                        .Append(@" title=""")
                        .Append(html.AttributeEncode(link.Title))
                        .Append(@"""");
                }
                sb.Append(@" href=""")
                    .Append(html.AttributeEncode(linkUrl))
                    .AppendLine(@""" />");
            }

            return MvcHtmlString.Create(sb.ToString());
        }
开发者ID:anycall,项目名称:Orchard,代码行数:21,代码来源:FeedManager.cs

示例3: GetLinks

        public MvcHtmlString GetLinks(HtmlHelper html)
        {
            var sb = new StringBuilder();
            foreach (var link in _links) {
                sb.Append("\r\n");
                sb.Append(@"<link");

                if (!string.IsNullOrEmpty(link.Rel)) {
                    sb
                        .Append(@" rel=""")
                        .Append(html.AttributeEncode(link.Rel))
                        .Append(@"""");
                }

                if (!string.IsNullOrEmpty(link.Type)) {
                    sb
                        .Append(@" type=""")
                        .Append(html.AttributeEncode(link.Type))
                        .Append(@"""");
                }

                if (!string.IsNullOrEmpty(link.Title)) {
                    sb
                        .Append(@" title=""")
                        .Append(html.AttributeEncode(link.Title))
                        .Append(@"""");
                }

                if (!string.IsNullOrEmpty(link.Href)) {
                    sb
                        .Append(@" href=""")
                        .Append(html.AttributeEncode(link.Href))
                        .Append(@"""");
                }

                sb.Append(@" />");
            }

            return MvcHtmlString.Create(sb.ToString());
        }
开发者ID:mofashi2011,项目名称:orchardcms,代码行数:40,代码来源:ResourceManager.cs

示例4: CreateNonceAttribute

 private static HtmlString CreateNonceAttribute(HtmlHelper helper, string nonce)
 {
     var sb = "nonce=\"" + helper.AttributeEncode(nonce) + "\"";
     return new HtmlString(sb);
 }
开发者ID:modulexcite,项目名称:NWebsec,代码行数:5,代码来源:CspHtmlHelpers.cs

示例5: GetValue

        public static string GetValue(HtmlHelper helper, object item, DataColumnOptions field)
        {
            var r = string.Empty;

            if (field.EditorType == DataColumnEditorTypes.Image)
            {
                var col = field as ImageColumnOptions;

                var valUrl = InspectDataFormat(item, field, col.ImageUrlFormat);
                if (valUrl == null)
                    return r;

                r += "<img src='" + valUrl + "'";
                if (col.ImageSize.Height > 0)
                    r += " height='" + helper.AttributeEncode(col.ImageSize.Height.ToString()) + "'";
                if (col.ImageSize.Width > 0)
                    r += " width='" + helper.AttributeEncode(col.ImageSize.Width.ToString()) + "'";
                r += "/>";
            }
            else if (field.EditorType == DataColumnEditorTypes.Link)
            {
                var col = field as LinkColumnOptions;
                var valUrl = InspectDataFormat(item, field, col.NavigateUrlFormat);
                if (valUrl == null)
                    return r;

                r += "<a href='" + valUrl + "'";
                if (!string.IsNullOrWhiteSpace(col.Target))
                    r += " target='" + col.Target + "'";
                r += ">" + col.Caption + "</a>";
            }
            else // LABEL VE HTMLLABEL
            {
                var val = InspectDataFormat(item, field);
                if (val == null)
                    return r;

                if (val.GetType().FullName == "System.Boolean")
                {
                    bool bVal;
                    if (bool.TryParse(val.ToString(), out bVal))
                    {
                        r += "<input type='checkbox' disabled='disabled' value='" + bVal + "'";
                        if (bVal)
                            r += " checked='checked'";
                        r += "/>";
                    }
                    else r = helper.Encode(val);
                }
                else if (val.GetType().FullName.IndexOf("System.DateTime") > -1)
                {
                    DateTime bVal;
                    r = helper.Encode(DateTime.TryParse(val.ToString(), out bVal) ? bVal.ToString(field.Format) : val);
                }
                else if (val.GetType().FullName.IndexOf("System.Int32") > -1)
                {
                    int bVal;
                    r = helper.Encode(int.TryParse(val.ToString(), out bVal) ? bVal.ToString(field.Format) : val);
                }
                else if (val.GetType().FullName.IndexOf("System.Decimal") > -1)
                {
                    decimal bVal;
                    r = helper.Encode(decimal.TryParse(val.ToString(), out bVal) ? bVal.ToString(field.Format) : val);
                }
                else
                {
                    r = field.EditorType == DataColumnEditorTypes.Label ? helper.Encode(val.ToString()) : val.ToString();
                }
            }
            return r;
        }
开发者ID:alibarut,项目名称:EasyGrid,代码行数:71,代码来源:ValueConverter.cs


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