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

  • SEARCH
  • Home
  • 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 7875423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:58:46+00:00 2026-06-03T02:58:46+00:00

I want to create a layout like the User page on Stack Overflow where

  • 0

I want to create a layout like the User page on Stack Overflow where there is a view (the parent view) at the top of the page and then content in tabs, each with it’s own view (child views).

When I hover over each of the tabs on the User page in SO it looks like they are pointed at the user controller and are being sent the tab name in the query string to render the appropriate tab content.

I believe I can achieve this using a layout with a section defined in the parent view. The section would be the child view, but I don’t know how I would tell the section which view or partial view to show.

I have not been able to find anything useful on the web. Can someone tell me how to do this or at least point me in the right direction?

Thanks in advance!

Edit: Thanks to @Mystere’s help I was able to come up with the solution below in case anyone else is trying to do the same thing.

HTH

Final Solution:

Controller Actions

public ActionResult Details(int id, string tab = null)
{   
    ViewBag.Jobid = id;
    ViewBag.Tab = tab ?? "Services";

    var viewModel = getJobRecordDetails(id);

    return View(viewModel);
}

public ActionResult JobInfo(int id, string tab)
{
    ViewBag.Jobid = id;
    ViewBag.Tab = tab;

    if (tab == "Services")
    {
        var viewModel = getServices(id);
        return View("Services", viewModel);   
    }

    if (tab == "Equipment")
    {
        var viewModel = getEquipment(id);
        return View("Equipment", viewModel);
    }

    if (tab == "Personnel")
    {
        var viewModel = getPersonnel(id);
        return View("Personnel", viewModel);
    }

    return View("Error");
}

Parent View

@model MyApplication.Models.JobViewModel

@{
    ViewBag.Title = "Details";
}
<h2>Job Details</h2>

...
@* Child View Action *@
@Html.Action("JobInfo", new { id = ViewBag.Jobid, tab = ViewBag.Tab })

Child View

@model MyApplication.Models.ServicesViewModel[]

@{
    ViewBag.Title = "Services";
    Layout = null;
}

@* Submenu Navigation *@
@{
    Html.RenderPartial("SubMenu");
}

<h2>Services</h2>

Services here...

Subnavigation Partial View

<div id="submenucontainer">
<ul id="submenu">
    <li class="@Html.ActiveTab("Job","JobInfo","Services")"><a href="@Url.Action("Details", "Job", new { id = @ViewBag.Jobid, tab = "Services" })">Services</a> </li>
    <li class="@Html.ActiveTab("Job","JobInfo","Equipment")"><a href="@Url.Action("Details", "Job", new { id = @ViewBag.Jobid, tab = "Equipment" })">Equipment</a></li>
    <li class="@Html.ActiveTab("Job","JobInfo","Personnel")"><a href="@Url.Action("Details", "Job", new { id = @ViewBag.Jobid, tab = "Personnel" })">Personnel</a></li>
</ul>

ActiveTab Helper

public static string ActiveTab(this HtmlHelper helper, string controller, string action, string tab)
{
    var classValue = "";

    var currentController =
            helper.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString();

    var currentAction =
            helper.ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();

    var currentTab = helper.ViewContext.Controller.ValueProvider.GetValue("tab").RawValue.ToString();

    if (currentController == controller && currentAction == action && currentTab == tab)
        classValue = "selected";

    return classValue;
}
  • 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-03T02:58:47+00:00Added an answer on June 3, 2026 at 2:58 am

    It is unlikely they are using a section for that. sections are used primarily in layout pages (the equivelent of master pages).

    More than likely, they just have multiple views, and they pass whichever view is appropriate to the View() method. They might use partial views, or MVC templates to render the tab areas, so that common code is factored out.

    Edit:

    As requested, code sample:

    In action method:

    public ActionResult Dashboard(string tab) {
        if (tab == "summary") 
            ViewBag.Tab = "~/Views/Dashboard/Summary.cshtml";
        if (tab == "activity")
            ViewBag.Tab = "~/Views/Dashboard/Activity.cshtml";
    
        return View()
    }
    

    in Dashboard.cshmtl

    ... your parent view
    
    @Html.Partial(ViewBag.Tab)
    
    ... your footer
    

    It’s not rocket science. There are so many ways to do this it doesn’t take much thought to come up with one of them.

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

Sidebar

Related Questions

I want to create a layout in such a way that on top edittext
I've got a problem with my page's layout. I want to create 3 table
I want to create a layout that has small panels at the top and
I want to create separate folders for my layouts, like this in my resource
I'm new to android development and needs help here.I want to create a layout
I want to create a multicolumn layout in html that will run from left
I want to create a Button otherthan creating it from xml layout.i want to
I want to render a view when user clicks on Add New button on
I want to allow users to create tiny templates that I then render in
I want to create a modules layout in my web application so I can

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.