src/ZKEACMS.FormGenerator/HtmlHelperExt.cs

(完整代码) 1KB

/* http://www.zkea.net/ 
 * Copyright (c) ZKEASOFT. All rights reserved. 
 * http://www.zkea.net/licenses */

using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using ZKEACMS.FormGenerator.Models;
using Easy.Extend;
using Easy.Serializer;

namespace ZKEACMS.FormGenerator
{
    public static class HtmlHelperExt
    {
        public static IHtmlContent DisplayFieldValue(this IHtmlHelper html, FormField field)
        {
            HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
            if ((field.Name == "Checkbox" || field.Name == "Radio" || field.Name == "Dropdown") && field.FieldOptions != null)
            {
                htmlContentBuilder.AppendHtml(string.Join("<br/>", field.FieldOptions.Where(m => m.Selected ?? false).Select(m => m.DisplayText)));
            }
            else if (field.Name == "Address" && field.Value.IsNotNullAndWhiteSpace())
            {
                htmlContentBuilder.Append(string.Join(" ", JsonConverter.Deserialize<string[]>(field.Value)));
            }
            else
            {
                htmlContentBuilder.Append(field.Value);
            }
            return htmlContentBuilder;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。