如何将 Kendo Mvc Tabstrip 的内联模板移动到部分
How to move Inline Template of Kendo Mvc Tabstrip into partial
我目前有以下 kendo 带内联模板的标签条:
@(Html.Kendo()
.TabStrip()
.BindTo(Model.Sections, (tabStripItem, tab) =>
{
tabStripItem.Text = tab.SectionName;
tabStripItem.Template.InlineTemplate = @<text>
<div>
<p>
@Html.DisplayFor(m => tab.SectionName)
</p>
<p>Questions</p>
<ul>
@foreach (var answer in tab.InterviewReportAnswers)
{
<li>
@Html.DisplayFor(m => answer.Question) : @Html.DisplayFor(m => answer.Answer)
</li>
}
</ul>
</div>
</text>;
}))
上面的工作正常,但是,我预计模板会变得更复杂,所以有没有办法将内联模板移动到外部部分文件?
事实证明,可以使用内置的 MVC 助手 partial
来实现这一点。
tabStripItem.Template.InlineTemplate = (@<text>
@Html.Partial("_InterviewSection", tab)
</text>);
我目前有以下 kendo 带内联模板的标签条:
@(Html.Kendo()
.TabStrip()
.BindTo(Model.Sections, (tabStripItem, tab) =>
{
tabStripItem.Text = tab.SectionName;
tabStripItem.Template.InlineTemplate = @<text>
<div>
<p>
@Html.DisplayFor(m => tab.SectionName)
</p>
<p>Questions</p>
<ul>
@foreach (var answer in tab.InterviewReportAnswers)
{
<li>
@Html.DisplayFor(m => answer.Question) : @Html.DisplayFor(m => answer.Answer)
</li>
}
</ul>
</div>
</text>;
}))
上面的工作正常,但是,我预计模板会变得更复杂,所以有没有办法将内联模板移动到外部部分文件?
事实证明,可以使用内置的 MVC 助手 partial
来实现这一点。
tabStripItem.Template.InlineTemplate = (@<text>
@Html.Partial("_InterviewSection", tab)
</text>);