包括在一个页面的多个视图 [英] Including multiple views in one page

查看:335
本文介绍了包括在一个页面的多个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器,它呈现一个视图(〜/查看/分量/ Create.aspx)没有问题。

I have a controller which renders a view (~/Views/Component/Create.aspx) no problem.

在显示这种看法,我想无论是:

When this view is displayed, I would like to either:

(1)当用户点击一个链接,在一个模式弹出(这里没问题)上,显示视图(而不是局部视图),但是从一个完整的ASPX视图(〜/查看/ TransportType /的Index.aspx)

(1) when a user clicks on a link, in a modal popup (no problem here), display a view (NOT A PARTIAL VIEW) but a complete aspx view from (~/Views/TransportType/Index.aspx)

为什么呢?由于(〜/查看/ TransportType /的Index.aspx)为100%的事情应该是这样,它有自己呈现在TransportType控制器部分景色。因此,在一个屏幕上我给用户的能力(插入/更新/编辑/删除)不用去各种屏幕。

Why? Because (~/Views/TransportType/Index.aspx) is 100% the way it should be and it has itself renders partial views from the TransportType controller. So, in one screen i give the user the ability to (Insert / Update / Edit / Delete) without going to various screens.

(2)内(〜/查看/组件/创建)我会满足于渲染的<%= Html.RenderAction(指数,TransportType)%的地方>在专区内的页面,我可以切换使用JavaScript。只有当我做尝试使用这种方法,我得到了CS1502:为System.IO.TextWriter.Write(char)的最佳重载的方法匹配具有一些无效参数

(2) within the (~/Views/Component/Create) i would settle for rendering the <%= Html.RenderAction("Index", "TransportType") %> somewhere in the page within a div that i can toggle using JavaScript. Only when i do try to use this approach I get the CS1502: The best overloaded method match for 'System.IO.TextWriter.Write(char)' has some invalid arguments.

请注意:我可以直接浏​​览到www.MySite.com/TransportType/Index没有问题,但如果我尝试使用上面#2描述的方法,我得到上面的后续错误

Note: I can browse directly to www.MySite.com/TransportType/Index with no problem, but if i try to use the methodology described in #2 above, i get the subsequent error above.

我已经尝试了一切。我投资我整天为试图弄清楚这一点。我可以很容易地实现速战速决,但那就否定了整个卖点一点上,我说服我公司相对于MVC和它的优点超过code-后面。请帮助我或者可能要回滚到code后面的ASP.NET世界。

I have tried everything. I invested my entire day into trying to figure this out. I can easily implement a quick fix, but then it would negate the whole selling point i'm convincing my company of relative to MVC and its advantages over code-behind. Please help or i may have to roll back to the ASP.NET world of code behind.

底线:没有人知道如何在视图中渲染的观点还是我问的问题错了

Bottom line: "Does anyone know how to render views within views? Or am i asking the question wrong.

下面是一些code:

推荐答案

如果您使用jQuery的用户界面,您可以使用该对话框的方法。

If you use jquery-ui you can use the dialog method.

例如:

<a href="<%=Url.Action("Index","TransportType") %>" id="transports">Types</a>
<div id="window"></div>
<script type="text/javascript">

$(document).ready(function(){
    $("#transports").click(function(){
        $("#window").load(this.href).dialog({title:"transport list"});
        return false;
    });
});
</script>

编辑:要使用Html.RenderAction不要把 = 之前,提出一个; 末为它不返回任何东西:&LT;%Html.RenderAction(指数,TransportType); %GT;

To use the Html.RenderAction do not put = before and puts a ; at the end as it is not returning anything: <% Html.RenderAction("Index", "TransportType"); %>

这篇关于包括在一个页面的多个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆