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


C# HtmlHelper.Raw方法代码示例

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


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

示例1: GetOutputJavascript

        private static string GetOutputJavascript(HtmlHelper helper, dynamic ngon, string @namespace)
        {
            var builder = new StringBuilder();
            builder.AppendFormat("window.{0}={{}};", @namespace);

            foreach (var prop in ngon)
            {
                builder.AppendFormat("{0}.{1}={2};", @namespace, prop.Key, helper.Raw(JsonConvert.SerializeObject(prop.Value)));
            }

            return builder.ToString();
        }
开发者ID:brooklynDev,项目名称:NGon,代码行数:12,代码来源:HtmlHelperExtensions.cs

示例2: EncodeOrDisplay

        /// <summary>
        /// Encode a value if it's a string, or render it if it's a Shape
        /// </summary>
        private IHtmlString EncodeOrDisplay(dynamic Value, dynamic Display, HtmlHelper Html) {
            if (Value is IHtmlString) {
                return Value;
            }

            if (Value is IShape) {
                return Display(Value).ToString();
            }
            
            return Html.Raw(Html.Encode(Value.ToString()));
        }
开发者ID:Golone,项目名称:Orchard,代码行数:14,代码来源:CoreShapes.cs

示例3: ActionLink

        public IHtmlString ActionLink(HtmlHelper Html, UrlHelper Url, dynamic Shape, dynamic Display, object Value) {
            var RouteValues = (object)Shape.RouteValues;
            RouteValueDictionary rvd;
            if (RouteValues == null) {
                rvd = new RouteValueDictionary();
            }
            else {
                rvd = RouteValues is RouteValueDictionary ? (RouteValueDictionary)RouteValues : new RouteValueDictionary(RouteValues);
            }

            var action = Url.Action((string)rvd["action"], (string)rvd["controller"], rvd);

            IEnumerable<string> classes = Shape.Classes;
            IDictionary<string, string> attributes = Shape.Attributes;
            attributes["href"] = action;
            string id = Shape.Id;
            var tag = GetTagBuilder("a", id, classes, attributes);
            tag.InnerHtml = EncodeOrDisplay(Value, Display, Html).ToString();

            return Html.Raw(tag.ToString());
        }
开发者ID:Golone,项目名称:Orchard,代码行数:21,代码来源:CoreShapes.cs

示例4: ResourceFileValueToHtml

        /// <summary>
        /// Format a resource string for HTML display. For
        /// now, it will only convert new lines to br tags.
        /// </summary>
        public static IHtmlString ResourceFileValueToHtml(HtmlHelper helper, string str)
        {
            var formattedString = str.Replace(Environment.NewLine, "<br/>");

            return helper.Raw(formattedString);
        }
开发者ID:niklasmelinder,项目名称:NExtra,代码行数:10,代码来源:ResourceFileValueHelper.cs

示例5: RenderFileWithVersion

        static IHtmlString RenderFileWithVersion(HtmlHelper html, string fileName,string fileWrap)
        {
            //if (fileName.StartsWith("~"))
            //{
            //    var area =(string) html.ViewContext.RouteData.DataTokens["area"];
            //    if (area.IsNotNull())
            //        fileName = fileName.Replace("~", "/Areas/" + area);

            //}

            string mcvscript = string.Empty;
            if (fileName.IndexOf('?') > 0)
            {
                mcvscript = string.Format(JsFileWrap, fileName);
            }
            else
            {
                var filewithverison = HttpRuntime.Cache[fileName];
                if (filewithverison == null)
                {
                    var filePath = PathHelper.MapPath(fileName);
                    var version = new FileInfo(filePath).LastWriteTime.ToString("yyyyMMddHHmmss");
                    filewithverison = fileName + "?" + version;
                    CacheDependency cdy = new CacheDependency(filePath);
                    HttpRuntime.Cache.Insert(fileName, filewithverison, cdy);

                }
                mcvscript = string.Format(fileWrap, filewithverison);
            }

            return html.Raw(mcvscript);
        }
开发者ID:alittletired,项目名称:SolutionPlatform,代码行数:32,代码来源:JavascriptExtensions.cs

示例6: Form

public static System.Web.WebPages.HelperResult Form(HtmlHelper htmlHelper, INode node, IEnumerable<IInvokeableParameter> fieldsToDisplay)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {



#line 53 "..\..\Helpers\NoodlesHelper.cshtml"
 
    if (node != null)
    {
        Func<dynamic, HelperResult> initHtml = (item => new System.Web.WebPages.HelperResult(__razor_template_writer => {

#line default
#line hidden


WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n");



#line 57 "..\..\Helpers\NoodlesHelper.cshtml"
      
        var isNodeMethod = node is NodeMethod;
        var fields = fieldsToDisplay as IInvokeableParameter[] ?? fieldsToDisplay.ToArray();
        if (isNodeMethod || fields.Any())
        {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "        <form class=\"node-form\" action=\"");



#line 62 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, node.Url);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\" method=\"POST\" enctype=\"multipart/form-data\">\r\n");



#line 63 "..\..\Helpers\NoodlesHelper.cshtml"
              
            var descriptionAttribute = node.Attributes.OfType<DescriptionAttribute>().SingleOrDefault();
            if (descriptionAttribute != null)
            {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "                <div class=\"noodles-callout noodles-callout-info\">\r\n             " +
"       ");



#line 68 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_template_writer, htmlHelper.Raw(descriptionAttribute.Description));

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n                </div>\r\n");



#line 70 "..\..\Helpers\NoodlesHelper.cshtml"
            }
            

#line default
#line hidden



#line 72 "..\..\Helpers\NoodlesHelper.cshtml"
             if (htmlHelper.ViewData.ModelState.SelectMany(ms => ms.Value.Errors).Any())
            {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "                <div class=\"noodles-callout noodles-callout-danger\">\r\n           " +
"         Please correct the issues below: ");



#line 75 "..\..\Helpers\NoodlesHelper.cshtml"
        WebViewPage.WriteTo(@__razor_template_writer, htmlHelper.ValidationSummary(true));

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\r\n                </div>\r\n");



#line 77 "..\..\Helpers\NoodlesHelper.cshtml"
//.........这里部分代码省略.........
开发者ID:genoher,项目名称:Noodles,代码行数:101,代码来源:NoodlesHelper1.generated.cs

示例7: NodeLink

public static System.Web.WebPages.HelperResult NodeLink(HtmlHelper htmlHelper, INode node, string additionalClasses, Func<dynamic, HelperResult> innerHtml)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {



#line 19 "..\..\Helpers\NoodlesHelper.cshtml"
 
    if (node != null)
    {
        Func<dynamic, HelperResult> initHtml = (item => new System.Web.WebPages.HelperResult(__razor_template_writer => {

#line default
#line hidden


WebViewPage.WriteLiteralTo(@__razor_template_writer, "<a class=\"node-link ");



#line 22 "..\..\Helpers\NoodlesHelper.cshtml"
                         WebViewPage.WriteTo(@__razor_template_writer, additionalClasses ?? "");

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, " ");



#line 22 "..\..\Helpers\NoodlesHelper.cshtml"
                                                    WebViewPage.WriteTo(@__razor_template_writer, node.Name);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\" href=\"");



#line 22 "..\..\Helpers\NoodlesHelper.cshtml"
                                                                       WebViewPage.WriteTo(@__razor_template_writer, node.Url);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "\">");



#line 22 "..\..\Helpers\NoodlesHelper.cshtml"
                                                                                  WebViewPage.WriteTo(@__razor_template_writer, innerHtml(null));

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_template_writer, "</a>");



#line 22 "..\..\Helpers\NoodlesHelper.cshtml"
                                                                                                                                                 }));
        var html = initHtml(null).ToHtmlString();
        foreach (var transformAtt in node.Attributes.OfType<ITransformHtml>())
        {
            html = transformAtt.Transform(htmlHelper, node, html).ToHtmlString();
        }
    
#line default
#line hidden


#line 28 "..\..\Helpers\NoodlesHelper.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, htmlHelper.Raw(html));

#line default
#line hidden


#line 28 "..\..\Helpers\NoodlesHelper.cshtml"
                         
    }

#line default
#line hidden

});

}
开发者ID:genoher,项目名称:Noodles,代码行数:89,代码来源:NoodlesHelper1.generated.cs

示例8: InfoDicItemsJsonArray

 private static IHtmlString InfoDicItemsJsonArray(HtmlHelper html, IEnumerable<IInfoDicItem> dicItems)
 {
     if (dicItems == null)
     {
         return html.Raw("[]");
     }
     var sb = new StringBuilder();
     sb.Append("[");
     int l = sb.Length;
     foreach (var item in dicItems)
     {
         if (item.IsEnabled != 1)
         {
             continue;
         }
         if (sb.Length > l)
         {
             sb.Append(",");
         }
         sb.Append("{")
             .Append("'code':").Append("'").Append(item.Code).Append("'")
             .Append(",'name':").Append("'").Append(item.Code).Append(" | ").Append(item.Name).Append("'");
         sb.Append("}");
     }
     sb.Append("]");
     return html.Raw(sb.ToString());
 }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:27,代码来源:ViewModelExtensions.cs

示例9: DicItemJsonArray

        /// <summary>
        /// 
        /// </summary>
        /// <param name="html"></param>
        /// <param name="dicCode"></param>
        /// <param name="prifix"></param>
        /// <returns></returns>
        private static IHtmlString DicItemJsonArray(HtmlHelper html, string dicCode, string prifix = "anycmd.")
        {
            var value = "[]";
            var sb = new StringBuilder();
            sb.Append("[");
            int l = sb.Length;
            var code1 = prifix + dicCode;
            var dicItems = html.CurrentHost().CatalogSet.Where(a => a.Code.StartsWith(code1, StringComparison.OrdinalIgnoreCase) && !a.Code.Equals(code1, StringComparison.OrdinalIgnoreCase));
            foreach (var item in dicItems)
            {
                var code = item.Code;
                if (sb.Length > l)
                {
                    sb.Append(",");
                }
                if (code1.Equals("anycmd.YesOrNoBoolean", StringComparison.OrdinalIgnoreCase))
                {
                    code = item.Code.Substring("anycmd.YesOrNoBoolean.".Length);
                }
                else if (code1.Equals("anycmd.YesOrNoNumber", StringComparison.OrdinalIgnoreCase))
                {
                    code = item.Code.Substring("anycmd.YesOrNoNumber.".Length);
                }
                sb.Append("{'code':").Append("'").Append(code).Append("'")
                    .Append(",'name':'").Append(item.Name).Append(" | ").Append(item.Code).Append("'}");
            }
            sb.Append("]");
            value = sb.ToString();

            return html.Raw(value);
        }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:38,代码来源:ViewModelExtensions.cs


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