Visual Studio格式不适用于Control + K + D和多行

LP1*_*P13 9 visual-studio razor kendo-asp.net-mvc

我正在使用Telerik的UI for ASP.NET小部件.大多数这些小部件都有多个配置选项.在.cshtml文件中,我在多行上配置这些小部件以提高可读性.
例如,下面是Grid小部件的配置.

<div class="row">
    <div class="col-md-12">
        @(Html.Kendo().Grid<ResultModel>()
            .Name("SearchGrid")            
            .Columns(col =>
            {
                col.Bound(p => p.DocumentID);
                col.Bound(p => p.UploadDate);
                col.Bound(p => p.DocumentType);
                col.Bound(p => p.ProcessStatus);                
                col.Bound(p => p.StateProvince);
                col.Bound(p => p.Error);                
                col.Bound(p => p.Notes);
            })
            .AutoBind(false)
            .Pageable()
            .Sortable()
            .Resizable(resize => resize.Columns(true))
            .Scrollable()
            .Sortable(sortable => sortable
                .AllowUnsort(true)
                .SortMode(GridSortMode.MultipleColumn))
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(50)
                .ServerOperation(true)
                .Read(read => read.Action("Search", "Search"))
       ).Deferred())
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

编辑cshtml文件后,我按下Control + K + D自动格式化.Visual Studio正确格式化html和一行中配置的任何内容.但是,在多行上配置的任何窗口小部件都会被一个选项卡缩进.因此,在上述情况下,一切从.Name("SearchGrid")).Deferred()))被一个标签缩进.

问题是,每一次我编辑CSHTML我按时间Control + K + D格式编辑CSHTML,而是由一个选项卡会使所有其他部件缩进.最终所有这些小部件都移动到页面的最右侧

Nic*_*ant 0

我找到了解决方案。在 @ 后面使用 { } 表示多行 Kendo Razor,它不受多个 Control + k + d 的影响。

@{
(Html.Kendo().DropDownList()
.Name("animatorEntityDropDownList")
.DataTextField("EntityName")
.DataValueField("EntityID")
.OptionLabel("- Select -")
.Events(e =>
{
e.Select("onSelectAnimatorEntityDropDownList");
})
.HtmlAttributes(new { style = "width:300px" }))
}
Run Code Online (Sandbox Code Playgroud)

  • @HunterNelson VS 2019 中的解决方案 https://developercommunity.visualstudio.com/content/problem/323902/razor-multiline-html-helper-formatting-indent-issu.html (2认同)