本文介绍了剑道部件在剃刀二级深,行内标记块不能嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试实施剑道部件两级深,但剃刀引擎一直在抱怨:。行内标记块(@Content)不能嵌套行内标记的只有一个级别被允许的

是否有剃刀引擎渲染佣工的方式两级深?

我的code例如:

  @(Html.Kendo()。TabStrip控件()
  。名称(标签栏)
  .Items(标签栏=>
      {
          tabstrip.Add()。文本(Strip1)
                  .Selected(真)
                  .Content(@<文字和GT;
                                @RenderPanelBar()
                            < /文本>);
          tabstrip.Add()。文本(Strip2)
                  .Content(@<文字和GT;                            < /文本>);
      })
)@helper RenderPanelBar(){
@(Html.Kendo()。PanelBar()
      。名称(panelBar)
      .ExpandMode(PanelBarExpandMode.Single)
      .Items(panelbar =>
          {
              panelbar.Add()。文本(PANEL1)
                      .Expanded(真)
                      .Content(@< D​​IV>
                                    < D​​IV>
                                        @(Html.Kendo()网格和LT; GroupViewModel>()
                                              。名称(GroupGrid)
                                              .Columns(列=>
                                                  {
                                                      columns.Bound(C => c.GroupID).Hidden();
                                                      columns.Bound(C => c.Name);
                                                      columns.Command(命令=> {command.Edit(); command.Destroy();});
                                                  })
                                              .ToolBar(工具栏=>
                                                  {
                                                      toolbar.Create();
                                                      toolbar.Template(@<文字和GT;
                                                                            @RenderDropDown()//< - 在这里出现错误
                                                                        < /文本>);
                                                  }
                                              )
                                              .Editable(编辑= GT; editable.Mode(GridEditMode.InLine))
                                              .Scrollable(S = GT; s.Enabled(假))
                                              .Selectable(S = GT; s.Enabled(真).Mode(GridSelectionMode.Single))
                                              .DataSource(数据源=>数据源
                                                                            阿贾克斯()
                                                                            .Read(读=> read.Action(Group_Grid_Read,家))
                                                                            .Events(事件=> events.Error(error_handler))
                                                                            。型号(型号=> model.Id(P => p.GroupID))
                                                                            .Create(更新=> update.Action(EditingInline_Create,家))
                                                                            .Update(更新=> update.Action(EditingInline_Update,家))
                                                                            .Destroy(更新=> update.Action(EditingInline_Destroy,家))
                                              )
                                              .Events(E =方式> e.Change(onGroupGridChange)保存(GroupGrid_Save))
                                          )
                                    < / DIV>
                                < / DIV>
                            < / DIV>);
              panelbar.Add()。文本(是Panel2)
                      .Content(@< D​​IV>
                                //东西缩写
                                < / DIV>
                  );
          })
  )
}
@helper RenderDropDown(){
< D​​IV CLASS =工具栏>
    <标签类=类别标签为=类别>显示产品按类别:< /标签>
    @(Html.Kendo()。DropDownList的()
        。名称(类)
        .OptionLabel(全部)
        .DataTextField(类别名称)
        .DataValueField(类别ID)
        .AutoBind(假)
        .Events(E => e.Change(categoriesChange))
        .DataSource(DS =>
            {
                ds.Read(ToolbarTemplate_Categories,网格);
            })
        )
< / DIV>
}


解决方案

我想你可能需要在任何级别使用剃刀帮手。你的情况,你可能需要把电网在另一 RenderGrid(),如下所示:

  @(Html.Kendo()。TabStrip控件()
  。名称(标签栏)
  .Items(标签栏=>
  {
      tabstrip.Add()。文本(Strip1)
          .Selected(真)
          .Content(@<文字和GT;
                        @RenderPanelBar()
                    < /文本>);
      tabstrip.Add()。文本(Strip2)
          .Content(@<文字和GT;                    < /文本>);
  })
  )@helper RenderPanelBar()
{
@(Html.Kendo()。PanelBar()
      。名称(panelBar)
      .ExpandMode(PanelBarExpandMode.Single)
      .Items(panelbar =>
      {
          panelbar.Add()。文本(PANEL1)
              .Expanded(真)
              .Content(@<文字和GT;
                            @RenderGrid()
                        < /文字和GT;
              );
          panelbar.Add()。文本(是Panel2)
              .Content(@< D​​IV>
                            //东西缩写
                        < / DIV>
              );
      })
      )
}
@helper RenderGrid()
{
@(Html.Kendo()网格和LT;&的usermodel GT;()
      。名称(GroupGrid)
      .Columns(列=>
      {
          columns.Bound(C => c.GroupID).Hidden();
          columns.Bound(C => c.Name);
          columns.Command(命令=>
          {
              command.Edit();
              command.Destroy();
          });
      })
      .ToolBar(工具栏=>
      {
          toolbar.Create();
          toolbar.Template(@<文字和GT;
                                @RenderDropDown()
                            < /文本>);
      })
      .Editable(编辑= GT; editable.Mode(GridEditMode.InLine))
      .Scrollable(S = GT; s.Enabled(假))
      .Selectable(S = GT; s.Enabled(真).Mode(GridSelectionMode.Single))
      .DataSource(数据源=> dataSource.Ajax()
          .Read(读=> read.Action(Group_Grid_Read,家))
          .Events(事件=> events.Error(error_handler))
          。型号(型号=> model.Id(P => p.GroupID))
          .Create(更新=> update.Action(EditingInline_Create,家))
          .Update(更新=> update.Action(EditingInline_Update,家))
          .Destroy(更新=> update.Action(EditingInline_Destroy,家)))
     .Events(E =方式> e.Change(onGroupGridChange)保存(GroupGrid_Save))
     )
 }@helper RenderDropDown()
{
 < D​​IV CLASS =工具栏>
                                    <标签类=类别标签为=类别>显示产品按类别:< /标签>
                                    @(Html.Kendo()。DropDownList的()
                                          。名称(类)
                                          .OptionLabel(全部)
                                          .DataTextField(类别名称)
                                          .DataValueField(类别ID)
                                          .AutoBind(假)
                                          .Events(E => e.Change(categoriesChange))
                                          .DataSource(DS => {ds.Read(ToolbarTemplate_Categories,网格);})
                                          )
                                < / DIV>
 }

I´m trying to implement Kendo widgets two level deep but the Razor engine keeps complaining: "Inline markup blocks (@Content) cannot be nested. Only one level of inline markup is allowed."

Is there a way for the Razor engine to render helpers two level deep?

My code example:

@(Html.Kendo().TabStrip()
  .Name("tabStrip")
  .Items(tabstrip =>
      {
          tabstrip.Add().Text("Strip1")
                  .Selected(true)
                  .Content(@<text>
                                @RenderPanelBar()
                            </text>);
          tabstrip.Add().Text("Strip2")
                  .Content(@<text>

                            </text>);
      })
)

@helper RenderPanelBar(){
@(Html.Kendo().PanelBar()
      .Name("panelBar")
      .ExpandMode(PanelBarExpandMode.Single)
      .Items(panelbar =>
          {
              panelbar.Add().Text("panel1")
                      .Expanded(true)
                      .Content(@<div>
                                    <div>
                                        @(Html.Kendo().Grid<GroupViewModel>()
                                              .Name("GroupGrid")
                                              .Columns(columns =>
                                                  {
                                                      columns.Bound(c => c.GroupID).Hidden();
                                                      columns.Bound(c => c.Name);
                                                      columns.Command(command => { command.Edit(); command.Destroy(); });
                                                  })
                                              .ToolBar(toolbar =>
                                                  {
                                                      toolbar.Create();
                                                      toolbar.Template(@<text>
                                                                            @RenderDropDown()  //<-- here the error occurs
                                                                        </text>);
                                                  }
                                              )
                                              .Editable(editable => editable.Mode(GridEditMode.InLine))
                                              .Scrollable(s => s.Enabled(false))
                                              .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single))
                                              .DataSource(dataSource => dataSource
                                                                            .Ajax()
                                                                            .Read(read => read.Action("Group_Grid_Read", "Home"))
                                                                            .Events(events => events.Error("error_handler"))
                                                                            .Model(model => model.Id(p => p.GroupID))
                                                                            .Create(update => update.Action("EditingInline_Create", "Home"))
                                                                            .Update(update => update.Action("EditingInline_Update", "Home"))
                                                                            .Destroy(update => update.Action("EditingInline_Destroy", "Home"))
                                              )
                                              .Events(e => e.Change("onGroupGridChange").Save("GroupGrid_Save"))
                                          )
                                    </div>
                                </div>
                            </div>);
              panelbar.Add().Text("panel2")
                      .Content(@<div>
                                //stuff abbreviated
                                </div>
                  );
          })
  )
}


@helper RenderDropDown(){
<div class="toolbar">
    <label class="category-label" for="category">Show products by category:</label>
    @(Html.Kendo().DropDownList()
        .Name("categories")
        .OptionLabel("All")
        .DataTextField("CategoryName")
        .DataValueField("CategoryID")
        .AutoBind(false)
        .Events(e => e.Change("categoriesChange"))
        .DataSource(ds =>
            {
                ds.Read("ToolbarTemplate_Categories", "Grid");
            })
        )
</div>
}
解决方案

I think you probably need to use razor helper at any level. In your case, you probably need to put the grid in another RenderGrid() as shown below:

@(Html.Kendo().TabStrip()
  .Name("tabStrip")
  .Items(tabstrip =>
  {
      tabstrip.Add().Text("Strip1")
          .Selected(true)
          .Content(@<text>
                        @RenderPanelBar()
                    </text>);
      tabstrip.Add().Text("Strip2")
          .Content(@<text>

                    </text>);
  })
  )

@helper RenderPanelBar()
{
@(Html.Kendo().PanelBar()
      .Name("panelBar")
      .ExpandMode(PanelBarExpandMode.Single)
      .Items(panelbar =>
      {
          panelbar.Add().Text("panel1")
              .Expanded(true)
              .Content(@<text>
                            @RenderGrid()
                        </text>
              );
          panelbar.Add().Text("panel2")
              .Content(@<div>
                            //stuff abbreviated
                        </div>
              );
      })
      )
}
@helper RenderGrid()
{
@(Html.Kendo().Grid<UserModel>()
      .Name("GroupGrid")
      .Columns(columns =>
      {
          columns.Bound(c => c.GroupID).Hidden();
          columns.Bound(c => c.Name);
          columns.Command(command =>
          {
              command.Edit();
              command.Destroy();
          });
      })
      .ToolBar(toolbar =>
      {
          toolbar.Create();
          toolbar.Template(@<text>
                                @RenderDropDown()
                            </text>);
      })
      .Editable(editable => editable.Mode(GridEditMode.InLine))
      .Scrollable(s => s.Enabled(false))
      .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single))
      .DataSource(dataSource => dataSource.Ajax()
          .Read(read => read.Action("Group_Grid_Read", "Home"))
          .Events(events => events.Error("error_handler"))
          .Model(model => model.Id(p => p.GroupID))
          .Create(update => update.Action("EditingInline_Create", "Home"))
          .Update(update => update.Action("EditingInline_Update", "Home"))
          .Destroy(update => update.Action("EditingInline_Destroy", "Home")))
     .Events(e => e.Change("onGroupGridChange").Save("GroupGrid_Save"))
     )
 }

@helper RenderDropDown()
{
 <div class="toolbar">
                                    <label class="category-label" for="category">Show products by category:</label>
                                    @(Html.Kendo().DropDownList()
                                          .Name("categories")
                                          .OptionLabel("All")
                                          .DataTextField("CategoryName")
                                          .DataValueField("CategoryID")
                                          .AutoBind(false)
                                          .Events(e => e.Change("categoriesChange"))
                                          .DataSource(ds => { ds.Read("ToolbarTemplate_Categories", "Grid"); })
                                          )
                                </div>
 }

这篇关于剑道部件在剃刀二级深,行内标记块不能嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 00:37