且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

内联标记块 (@<p>Content</p>) 不能嵌套.只允许一级内联标记

更新时间:2022-10-19 12:16:26

我想通了.

我必须链接帮手.

所以每个多选都有一个辅助类.

按照这个: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>);