18

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>      
2
  • 6
    do you really want to use jquery tabs as the primary naviation mechanism on your site? seems like a bad idea... users can't bookmark specific parts of the site, you can't as easily redirect them to specific parts of the site, and if the user has javascript disabled then they can't use your site at all. jquery tabs are very cool but this usage of them goes too far, imo Jan 25, 2011 at 3:46
  • Robert, very good points. I'm actually thinking about removing them for some of those reasons and more. It ups the difficulty when you have a very dynamic site, such as this will be. At least with the limited knowledge that I currently have.
    – KeelRisk
    Jan 25, 2011 at 4:51

1 Answer 1

30

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

3
  • 6
    When your views are rendered by a click on Ajax.ActionLink(..) then the RenderBody() is useless.
    – Pascal
    Apr 19, 2012 at 21:19
  • 1
    +1 this helped me, thanks SLaks! I'm migrating from webforms to MVC. :)
    – jomsk1e
    Jun 20, 2013 at 4:49
  • That doesn't answer the question? Due to the posters single page design and tab control the RenderBody simply isn't necessary.
    – pfeds
    Jul 28, 2017 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.