一页中的两个局部视图?

Two Partial Views in One Page?

我尝试在 1 个下使用 2 个局部视图 view/page - 上半页用于搜索过滤器,第二半页用于 table 显示。它也可以工作,但问题是白色内容面板的大小是固定的。即,如果我的 table 得到数据,它来自白色面板。

<section class="content admin_table">
   @RenderBody()
</section>

我在布局中使用 class 以上。在索引视图中,我渲染了两个部分视图。我的代码部分如下

 @Html.Partial("_view1", Model.Filter)
 @Html.Partial("_view2", Model.Result)

我的索引页

@model SW.Web.ViewModels.CommonVM
@{
    Layout = "~/Views/Shared/_Layout1.cshtml";
    ViewBag.Title = "Title";
    ViewBag.Header = "Details";
       }
<link href="~/Content2/plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" />

  <!DOCTYPE html>

@section JavaScript{

<Script> .....</script>
<Script> .....</script>
}
@Html.Partial("_view1", Model.Filter)
 @Html.Partial("_view2", Model.Result)

和我的局部视图 1

 @model SW.Web.ViewModels.viewmodel1 
     @{
    using (Html.BeginForm("Index", "Details", FormMethod.Post, new { d= Model }))
    {
        @Html.ValidationSummary(true)
  <div>.....Design</div>
}

和我的局部观点 2

 @model IEnumerable<SW.Web.ViewModels.Viewmodel2>
    @{
     <div> Designs for partial view 2</div>

}

所以创建一个视图 搜索像

这样的局部视图
//Serach view
<div class="white">
<h2>Search view</h2>
<--! search coading-->
   @Html.RenderPartial("Table_View", objectvalue2);
</div>

使用下行

 @Html.RenderPartial("_SearchView", objectvalue1);

在另一页中

  1. 来自 controller action

@Html.Action("action1", "Controller", new { id = Model.idOfPart1 })

@Html.Action("action2", "Controller", new { id = Model.idOfPart2 })

  1. 来自 rendering view

@Html.Render ("ParialView1", Model.model1)

@Html.Render ("PartialView2", Model.model2)

我知道这已经有一年多了,但以防万一有人偶然发现这个 post。 RenderPartialView 是这样写的:

@{@Html.RenderPartial("_yourPartial", yourModel)}