简体   繁体   English

在正确的位置渲染局部视图

[英]Render Partial View in Correct Location

Trying to: Place a partial view within a telerik tabstrip. 尝试:在Telerik Tabstrip中放置局部视图。

Problem: The view is being displayed above the tab strip instead of within the first tab. 问题:视图显示在选项卡条上方,而不是在第一个选项卡中。

What I have tried: If I use RenderPage instead of RenderAction then the view correctly appears inside the tabstrip however then the controller does not get called or load the model for the gridview. 我尝试过的操作:如果我使用RenderPage而不是RenderAction,则视图正确显示在Tabstrip内,但是不会调用控制器或为gridview加载模型。

Code so far: 到目前为止的代码:

Partial View: 部分视图:

@model IEnumerable<MyModel>

@{
    ViewBag.Title = "Index";
}

@*My code to load a GridView*@

View containing tab strip: 视图包含标签条:

@{
    ViewBag.Title = "MyView";
}


@(Html.Kendo().TabStrip()
          .Name("tabstrip")
          .Items(tabstrip =>
          {
              tabstrip.Add().Text("Index")
                  .Selected(true)
                  .Content(@<text>
                    @{Html.RenderAction("Index", "MyController");}
                </text>);
              tabstrip.Add().Text("Index2")
                  .Content(@<text>
                </text>);                                 
          })
)

The Content configuration method of a Kendo UI TabStrip should be used for "static" content. Kendo UI TabStrip的Content配置方法应用于“静态”内容。 By static I mean code that you already have/know. 静态是指您已经拥有/知道的代码。 For loading partial views it is best to use the LoadContentFrom configuration method. 要加载部分视图,最好使用LoadContentFrom配置方法。 This method requires a valid URL of an existing Action, which returns the targeted partial view: 此方法需要现有Action的有效URL,该URL返回目标部分视图:

@(Html.Kendo().TabStrip()
      .Name("tabstrip")
      .Items(tabstrip =>
      {
          tabstrip.Add().Text("Index")
              .Selected(true)
              .LoadContentFrom(Html.Action("Index", "MyController"));
          tabstrip.Add().Text("Index2")
              .Content(@<text>
            </text>);                                 
      })

)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM