javascript - 内联标记 block (@<p>Content</p>) 不能嵌套。只允许一层内联标记

标签 javascript asp.net-mvc asp.net-mvc-4 razor kendo-ui

您好,我收到错误消息:

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

将 Kendo UI 选项卡条和 MultiSelectBoxes 与 Razor View 和 MVC4 结合使用

我已经尝试实现辅助类,但我仍然遇到错误

这是我的代码,我是不是漏掉了一步?我将 3 个多选移出并用助手调用它们!

@(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);
                                          })

                                    )
}

最佳答案

我想通了。

我必须链接助手。

所以每个多选一个帮助类。

按照这个: http://www.aspnetwiki.com/telerik-mvc:nested-container-controls-and-razor-helper

然后,如果你想在一个选项卡中进行多个多选,你将需要为每个多选提供一个帮助程序,如下所示:

这是助手,只需将其复制到第二个、第三个和第四个,然后更改名称等...

@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);
                   })

          )
    }

然后像这样在 TabStrip 'Content' 中调用助手:

.Items(tabstrip =>
          {
              tabstrip.Add().Text("One")

                  .Content(@<text>
                                                       @RenderMultiSelectFirstBox() 
                                                       @RenderMultiSelectSecondBox()</text>);

关于javascript - 内联标记 block (@<p>Content</p>) 不能嵌套。只允许一层内联标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19917893/

相关文章:

javascript - 用 express.js 处理 Mongoose 连接的正确方法是什么?

javascript - Datepicker 在 Safari 和 FireFox 中不起作用

c# - MVC 4 表单例份验证 - 除了在 web.config 上声明的操作之外,无法访问任何其他操作

jquery - MVC 4 Razor 对象不支持属性或方法 'dataTable'

c# - VS 2013 中的 "This feature is only available for view with a strongly typed model",ASP,C#

asp.net-mvc - 如何在jqgrid中创建两个页脚行

JavaScript : cannot remove the listener for webkitAnimationEnd

javascript - 动态添加的输入字段立即消失

asp.net-mvc - LINQ to EF 有什么问题?

c# - MVC4 模型验证然后使用 JQuery 将 JSON post 提交到外部 URI