Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8374321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:53:53+00:00 2026-06-09T14:53:53+00:00

I am in the process of creating a prototype project using MVC 3 and

  • 0

I am in the process of creating a prototype project using MVC 3 and I have come across a situation which I can’t seem to find an answer for and it seems like I might be approaching the problem the wrong way.

A quick overview of my project; it is based on the MVC template you get with Visual Studio and I use the links (tabs) on the supplied _Layout view to access some of my other views. One of these links opens a second partial view that again contains links for more views (admin specific. hence the split). The problem I am having is that I can’t seem to display views with the @RenderBody in the second partial view, which I understand is because you can’t have more than one @RenderBody in a completed HTML file, which makes sense.

So my question is, how can I display the views in this manner? Also, probably more importantly, is this the correct way to achieve this ‘sub menu’ system I am trying for or is there a better way to achieve this?

Here is the relevant parts of the views, first is the ‘main’ _Layout file:

<body>
    <div class="page">
        <header>
            <div id="title">
                <h1>Test App</h1>
            </div>
            <nav>
                <ul id="menu">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    @if (User.Identity.IsAuthenticated)
                    {
                        <li>@Html.ActionLink("Contracts", "List", "Contract", new { user=User.Identity.Name, page=1 }, null)</li>
                    }
                    @if (User.IsInRole("Administrator"))
                    {
                        <li id="admin">@Html.ActionLink("Administration", "Administration", "Home")</li>
                    }
                </ul>
            </nav>
        </header>
        <section id="main">
            @RenderBody()
        </section>
        <footer>
        </footer>
    </div>
</body>

When clicking the <li id="admin">@Html.ActionLink("Administration", "Administration", "Home")</li> link, then the Home controller return the second partial view shown below:

<header>
    <div id="admintitle">
        <h1>Administration</h1>
    </div>  
</header>
<body>
    <div id="div-1a">
         <nav>
            <ul id="adminmenu">
                <li>@Html.ActionLink("Contact", "List", "Contact")</li>
                <li>@Html.ActionLink("Home", "Index", "Home")</li>
            </ul>
        </nav>
    </div>
    <div id="div-1c">
        <h1>Test</h1>   
    </div>
    <section id="adminmain">
        @RenderBody()
    </section>
</body>

When I try and run the code, it fails due to the second @RenderBody, which is understandable.

If you need any more information, then please let me know.

Thanks very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:53:54+00:00Added an answer on June 9, 2026 at 2:53 pm

    Convert

    From

    <section id="adminmain">
       @RenderBody()
    </section>
    

    To

       <div id="adminmain"></div>
    

    From

    @Html.ActionLink("Contact", "List", "Contact")
    

    To

    @Ajax.ActionLink("Contact", "List", "Contact", new AjaxOptions { UpdateTargetId = "adminmain" })
    

    And in ContactController List action return PartialView() instead of ‘View()’.

    Do not forget to include jquery.unobtrusive-ajax in your view to make Ajax work.

    And before all read Roman’s Answer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of creating a metasearch engine and I'm stuck! Using php
I'm in the process of creating a double-linked list, and have overloaded the operator=
I'm in the process of creating an app. I'd like to have a pared
I'm in the process of creating a small currency conversion script using the money.js
I am in process of creating my first app and have some confusion over
I'm in the process of creating my own framework and have been looking at
I'm in the process of creating a framework in which I provide the base
I'm in the process of creating a desktop screen capture application. I'm using a
I'm in the process of creating a CSR, and I wonder which is arguably
I am in process of creating a dialog IDD_DIALOG2 which i want to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.