首页 > 代码库 > 嵌套错误Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed

嵌套错误Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed

例子:

@{Html.Telerik().Splitter().Name("MainSplitter")    .Orientation(SplitterOrientation.Vertical)    .Panes(vPanes =>    {        vPanes.Add()            .Size("50px")            .Content(                @<text>                    Epx Studio                </text>            )        vPanes.Add()            .Content(                @<text>                    @{                        @Html.Telerik().TabStrip()                            .Items(tabstrip =>                            {                                tabstrip.Add()                                    .Text("Tab 1")                                    .Content(                                        @<text>                                            @RenderSection("tabOneContents", false);                                        </text>                                    );                            }                    }                </text>            );    })    .Render();}

 

嵌套@<text>错误,错误信息Inline markup blocks (@<p>Content</p>) cannot be nested. Only one level of inline markup is allowed

MVC 引擎不允许潜逃@<Text>,@<p> ,@div,

解决方案,用帮助方法,帮助方法(helper function(是在view里定义的方法,使用如下

 

{Html.Telerik().Splitter().Name("MainSplitter")    .Orientation(SplitterOrientation.Vertical)    .Panes(vPanes =>    {        vPanes.Add()            .Size("50px")            .Content(                @<text>                    Epx Studio                </text>            )        vPanes.Add()            .Content(                @<text>                    @RenderTabStrip()                </text>            );    })    .Render();}@helper RenderTabStrip(){    @{Html.Telerik().TabStrip()        .Items(tabstrip =>        {            tabstrip.Add()                .Text("Tab 1")                .Content(                    @<text>                        @RenderSection("tabOneContents", false);                    </text>                );        }    }}