在没有布局项目的IFRAME中加载控制器的视图

问题描述 投票:0回答:3

如果您不需要布局,那么您必须从这些控制器操作中返回部分视图。

ex.
asp.net .net asp.net-mvc-3
3个回答
1
投票
return PartialView("ViewName");

在_layout视图中,您可以使用iFrame生成目标链接,例如: -
<li>@Html.ActionLink("Contact", "Contact", "Home", null, new {target ="MainiFrame"})</li>

1
投票
在您的内容部分(在_layout视图中)如下: -

<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.......... *@

tollest说明您的视图不使用默认布局,其他明智的视图将加载您的所有_layout元素,例如菜单,横幅等
enjoy
    

如果您想完全隐藏布局,则可以将布局设置为null,例如:
@{
    Layout = null;
} 

但是,如果您只想在iframe中隐藏布局,则应

@{ if (Context.Request.Query["iframe"] == "true") { Layout = null; } }


0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.