在MVC布局页面中呈现两次 [英] In MVC layout page is rendered twice

查看:97
本文介绍了在MVC布局页面中呈现两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个包含renderbody()的布局页面。

如果我在的地方运行soulution renderbody显示整个页面布局

ie



布局设计



Renderbody(再次显示带有视图的layoutdesign)



任何人都可以帮我这个。



提前谢谢

解决方案

我在这里假设,

当我尝试制作jQuery回发并获得ActionResult时,这件事发生在我身上在Html格式中,如果要检查尝试将警报放入结果中。然后检查您的警报html代码将在您的下一个容器部门中再次显示您的布局页面代码。

背后的原因是你返回的是View而不是局部视图。如果你返回一个视图它将始终带有布局代码。

所以尝试返回局部视图。



希望这有助于

Hi,

I am having a layout page which contains renderbody().
If i run the soulution in the place of renderbody the whole page with layout is displayed
i.e

Layout design

Renderbody(again layoutdesign with view is displayed)

Could any one help me on this pls.

Thanks in advance

解决方案

I assumed here ,
This happened to me once when I tried to make a jQuery postback and getting a ActionResult in Html formate, if want to check try to put alert in result. and then check your alert html code will have your layout page code again in your next container division.
The reason behind that is you are returning a View not the partial view. and if you return a view It will always comes with the layout code.
so try to return an partial view .

Hope this helps.


这篇关于在MVC布局页面中呈现两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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