【发布时间】:2021-09-26 13:17:45
【问题描述】:
我正在尝试创建一个自定义下拉列表作为 HtmlHelper,以便像 Html.MyDropdown(x => x.MyList) 一样使用。我想像这样添加一个css文件:
public static class HtmlHelpers
{
public static IHtmlContent MyDropdown<TModel>(this IHtmlHelper<TModel> model, Expressoion<Func<TModel,DropdownViewModle>> expression)
{
var builder = new StringBuilder(@"<div class=""dropdown""/>");
// some other content here
builder.AppendLine("</div>")
// this is my question
builder.AppendLine("@section Styles{~/css/dropdown.css}");
builder.AppendLine("@section Scripts{~/js/dropdown.js}");
return new HtmlString(builder.ToString());
}
}
如何让助手添加 css 和 js 文件,以便实现者不必添加?
【问题讨论】:
标签: c# asp.net-core asp.net-core-mvc