内联标记块 (@<p>Content</p>) 不能嵌套.只允许一级内联标记 [英] Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed
问题描述
你好,我收到错误:
内联标记块(@<p>Content</p>)不能嵌套.只允许一级内联标记.
在 Razor 视图和 MVC4 中使用 Kendo UI 标签条和 MultiSelectBoxes
我已经尝试实现辅助类,但仍然出现错误
这是我的代码,我错过了一步吗?我将 3 个多选移出并用助手调用它们!
@(Html.Kendo().TabStrip().Name("标签条").Items(tabstrip =>{tabstrip.Add().Text("One").Content(@@RenderSelect(););tabstrip.Add().Text("两个").Content("两个");tabstrip.Add().Text("三").Content("三个");}).SelectedIndex(0))@helper 渲染选择(){<h2>我的列表</h2><label>一个</label>@(Html.Kendo().多选().Name("一个").自动绑定(真).Placeholder("选择客户...").DataTextField("hname").DataSource(源=>{source.Read(读=>{read.Action("Client", "Dist");}).ServerFiltering(true);}))<label>两个</label>@(Html.Kendo().多选().Name("两个").自动绑定(真).DataTextField("gname").Placeholder("选择收件人...").DataSource(源=>{source.Read(读=>{read.Action("Client", "Dist");}).ServerFiltering(true);}))<label>三</label>@(Html.Kendo().多选().Name("三个").自动绑定(真).DataTextField("id").Placeholder("选择CLL...").DataSource(源=>{source.Read(读=>{read.Action("Codes", "Dist");}).ServerFiltering(true);}))}
我想通了.
我必须链接帮手.
所以每个多选都有一个辅助类.
按照这个:http://www.aspnetwiki.com/telerik-mvc:nested-container-控制和剃刀助手
然后,如果您想在一个选项卡中进行多个多选,您将需要为每个多选提供一个助手,如下所示:
这是助手,只需将其复制到第二个第三个和第四个并更改名称等...
@helper RenderMultiFirstBox(){@(Html.Kendo().多选().Name("名字").自动绑定(真).Placeholder("选择第一个...").DataTextField("名称").DataSource(源=>{source.Read(读=>{read.Action("索引", "某事");}).ServerFiltering(true);}))}
然后像这样调用 TabStrip 'Content' 中的助手:
.Items(tabstrip =>{tabstrip.Add().Text("One").Content(@<文本>@RenderMultiSelectFirstBox()@RenderMultiSelectSecondBox()</text>);
Hello I am getting the error:
Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed.
Using a Kendo UI tabstrip and MultiSelectBoxes with a Razor View and MVC4
I have tried implementing the helper class, but I am still getting the error
Here is my code, am I missing a step? I moved the 3 multiselects out and called them with the helper!
@(Html.Kendo().TabStrip()
.Name("tabstrip")
.Items(tabstrip =>
{
tabstrip.Add().Text("One")
.Content(@<div>
@RenderSelect()
</div>;);
tabstrip.Add().Text("Two")
.Content("Two");
tabstrip.Add().Text("Three")
.Content("Three");
})
.SelectedIndex(0)
)
@helper RenderSelect()
{
<h2>MyList</h2>
<label>One</label>
@(Html.Kendo()
.MultiSelect()
.Name("One")
.AutoBind(true)
.Placeholder("Select Clients...")
.DataTextField("hname")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Client", "Dist");
})
.ServerFiltering(true);
})
)
<label>Two</label>
@(Html.Kendo()
.MultiSelect()
.Name("Two")
.AutoBind(true)
.DataTextField("gname")
.Placeholder("Select Recipients...")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Client", "Dist");
})
.ServerFiltering(true);
})
)
<label>Three</label>
@(Html.Kendo()
.MultiSelect()
.Name("Three")
.AutoBind(true)
.DataTextField("id")
.Placeholder("Select CLL...")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Codes", "Dist");
})
.ServerFiltering(true);
})
)
}
I figured it out.
I have to chain the helpers.
So One helper class for each of the multi-selects.
Follow This: http://www.aspnetwiki.com/telerik-mvc:nested-container-controls-and-razor-helper
Then If you want multiple MultiSelects In One Tab You will need to have a helper for each multiselect like this:
Here is the helper, just copy this for the second third and fourth and change the names etc...
@helper RenderMultiFirstBox()
{
@(Html.Kendo()
.MultiSelect()
.Name("First")
.AutoBind(true)
.Placeholder("Select First...")
.DataTextField("name")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("Index", "Something");
})
.ServerFiltering(true);
})
)
}
Then Call the helpers in the TabStrip 'Content' like this:
.Items(tabstrip =>
{
tabstrip.Add().Text("One")
.Content(@<text>
@RenderMultiSelectFirstBox()
@RenderMultiSelectSecondBox()</text>);
这篇关于内联标记块 (@<p>Content</p>) 不能嵌套.只允许一级内联标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!