本文介绍了与@RenderBody()做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带JQuery UI Tabs的ASP.NET MVC 3应用程序.我有一个主布局页面_layout.cshtml,下面的代码.主版_layout.cshtml需要@RenderBody()代码.既然是必需的,那我应该怎么做.我想我要使用的是我不知道我是否正确地执行了此操作,因为我没有使用它.
我应该是吗,如果不是,那是什么问题?
谢谢.

I have an ASP.NET MVC 3 application with JQuery UI Tabs. I have a master layout page _layout.cshtml, code below. The master _layout.cshtml requires a @RenderBody() code. Since it is required, what am I supposed to do with it. I guess where I'm going with this is I do not know if I'm doing this correctly, since I'm not using it.
Should I be and what are the problem if not ?
Thanks.

 <div class="page">
        <div id="title" style=" height:120px" >                
            <img alt="Test.com" src="/Content/images/TestLogoLeft.png" style="width:370px; float:left; margin:0px;" />
        </div>

        <div id="titleRight" style=" background-color:White; width:580px; height:120px; float:right;"></div>

        <div id="menu" style=" background-color:White; width:950px; height:400px; float:left;">

            <!-- Must have class= info to prevent flash of just content on refresh -->
            <div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all" style=" position:relative; border:0px;"   >
                <ul class="ui-tabs-nav">                        
                    <li><a href="#tabs-1" >Home</a></li>                        
                    <li><a href="#tabs-2" >Statistics</a></li>
                    <li><a href="#tabs-3" >Maps</a></li>
                    <li><a href="#tabs-4" >FAQs</a></li>
                    <li ><a href="#tabs-5">Login</a></li>
                    <li ><a href="#tabs-6">SignUp</a></li>
                </ul>
                <div id="tabs-1" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Home/Home") </div>
                <div id="tabs-2" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Statistics/Statistics")</div>
                <div id="tabs-3" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Maps/Maps")</div>
                <div id="tabs-4" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Home/FAQs")</div>                                     
               <div id="tabs-5" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Account/LogOn")</div>                                                        
               <div id="tabs-6" class="ui-tabs-hide ui-tabs-panel">@Html.Partial("../Account/Register")</div> 

            </div>               
        </div>               
 </div>


 @* TODO: I need to figure out what to do with this  *@        
<div id="main" style=" display:none">
    @RenderBody()           
</div>      

推荐答案

@RenderBody调用将呈现您实际视图的内容.
您应该将其放置在想要视图内容的任何位置.

The @RenderBody call will render the content of your actual view.
You should put it wherever you want the view's content to be.

这篇关于与@RenderBody()做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 14:49