jQuery 怎么处理@RenderBody()?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4789674/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:56:22  来源:igfitidea点击:

What to do with @RenderBody()?

asp.netjqueryasp.net-mvc

提问by KeelRisk

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.cshtmlrequires 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.

我有一个带有JQuery UI Tabs. 我有一个主布局页面_layout.cshtml,代码如下。主人_layout.cshtml需要一个@RenderBody()代码。既然是必须的,那我该怎么办。我想我要去哪里我不知道我是否正确地这样做,因为我没有使用它。
我应该是,如果不是,有什么问题?
谢谢。

 <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>      

回答by SLaks

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

@RenderBody调用将呈现您的实际视图的内容。
您应该将它放在您希望视图内容所在的任何位置。