Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

                                    )
}
like image 515
KeyboardFriendly Avatar asked Nov 11 '13 23:11

KeyboardFriendly


1 Answers

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>);
like image 163
KeyboardFriendly Avatar answered Oct 03 '22 17:10

KeyboardFriendly