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 6098987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:13:16+00:00 2026-05-23T13:13:16+00:00

We are gradually migrating a Spark based project to use Razor and I have

  • 0

We are gradually migrating a Spark based project to use Razor and I have come across something I can’t seem to find an answer to.

My line in my Spark master calls a sub View like so

<Sidebar>   
    <segment name="header"> 
        <div> <!-- header content--> </div>
    </segment>
    <segment name="content"> 
        <div> <!-- content content--> </div>
    </segment>
</Sidebar>

The Sidebar spark looks like so

<div id="sidebar" >
<div class="header">
    <render segment="header">
        <!-- placeholder -->
    </render>
</div>
<div class="ui-layout-content content">
    <render segment="content">
        <!-- placeholder -->
    </render>   
</div>

This renders with the content from the first section displayed in the layout from the second.
Is there some way I can recreate this using Razor. I can see that I need to use Partials, but I can’t see how to pass the content into the sidebar subview.

Essentially I’m trying to recreate the functionality that Spark calls Segments (or previously Sections) http://sparkviewengine.com/reference/elements#segmentpreviouslyknownassection

EDIT: More information.
I have an Index.cshtml that gets it’s layout from Application.cshtml. In here I have the markup code that goes into the Sidebar.cshtml partial.

If I add put @section header (which is rendered in the Sidebar.cshtml) in my Index.cshtml file it doesn’t recognise it as a valid section. I have @RenderSection("header", false) in my Sidebar.cshtml file.

How do I tie these 2 together?

So my hierarchy is as follows

Application.cshtml — Global page layout
Index.cshtml — Page layout including content for the sidebar
Sidebar.cshtml — Template / layoout for sidebar content from Index.cshtml

For example

in Index.cshtml

    @RenderPage("Sidebar") 
    @section SidebarHeader { <!--Title or something --> }
    @section SidebarContent { <!--Content --> }

Then in Sidebar.cshtml

    <div class="header">
        @RenderSection("SidebarHeader", false)
    </div>
    <div class="ui-layout-content content">
        @RenderSection("SidebarContent", false)
    </div>

The idea is that I can have a template in a sub-view that is populated with the content from the view. Meaning that I can template areas for other pages across the site. Eg. The sidebar content on another page will need the same format, but different content.

  • 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-05-23T13:13:17+00:00Added an answer on May 23, 2026 at 1:13 pm

    You can use Layouts and Sections to accomplish the same. See details here: http://weblogs.asp.net/scottgu/archive/2010/12/30/asp-net-mvc-3-layouts-and-sections-with-razor.aspx

    Index.cshtml:

    @RenderSection("Sidebar")
    

    Your sidebar.cshtml would look like this:

    <div id="sidebar" >
        <div class="header">
            @RenderSection("header", required: false)
        </div>
        <div class="ui-layout-content content">
            @RenderSection("content", required: false)  
        </div>
    </div>
    

    And sub view(s) like this (you can define them in one too but having them separate is probably better in the long term):

    SubViews.cshtml:

        @section header {
          <div> <!-- header content--> </div>
    
        }
    
        @section content {
          <div> <!-- content content--> </div>
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So we're gradually moving all our projects across into SVN, from CVS. One project
I have a User model, the user can gradually insert information on their profile
I have gradually abandonned my offline emailer and switched to an online one, but
In a project that I've been involved with for many years, I've gradually evolved
I have spent the last few months gradually tweaking my multi-monitor layout and shortcuts
Can php divide the page into small block and gradually appear? I divided my
I've been gradually piecing together how I can receive a serialized object within Spring
Say I want to have a server that can accept 2GB file over network,
Good Afternoon, I have a list being generated gradually on the users screen, (right
Gradually I've been using more variants - they can be very useful in certain

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.