如果您不需要布局,那么您必须从这些控制器操作中返回部分视图。
ex.return PartialView("ViewName");
在_layout视图中,您可以使用iFrame生成目标链接,例如: -
<li>@Html.ActionLink("Contact", "Contact", "Home", null, new {target ="MainiFrame"})</li>
<section class="content-wrapper main-content clear-fix">
@RenderBody()
<iframe name="MainiFrame" src="" width="920" height="1000" frameborder="0"></iframe>
</section>
然后您想在iframe中显示的任何视图,您可以在该视图的上角写下以下代码。
@model YourProgramName.YourModelClass
@{
Layout = null;
ViewBag.Title = "Your View Title";
}
@* Rest of your codes and mark ups.......... *@
enjoy
如果您想完全隐藏布局,则可以将布局设置为null,例如:
@{
Layout = null;
}
但是,如果您只想在iframe中隐藏布局,则应
@{
if (Context.Request.Query["iframe"] == "true")
{
Layout = null;
}
}