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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:34:31+00:00 2026-06-05T15:34:31+00:00

I have this _Layout.cshtml <body> <div id=wrapper> <div id=header-wrapper> <div id=header> <div id=logo> //SOME

  • 0

I have this _Layout.cshtml

<body>
    <div id="wrapper">
<div id="header-wrapper">
    <div id="header">
        <div id="logo">
                //SOME LOGO LOGIC

        </div>
    </div>
    <div id="menu-wrapper">

        //SOME MENU LOGIC

    </div>
    <!-- end #menu -->
    <div id="banner">
        <div id="slider"> <a href="#" class="button previous-button">&lt;</a> <a href="#" class="button next-button">&gt;</a>
            <div class="viewer">
                <div class="reel">
                    <div class="slide">
                        <h2>Stallen..</h2>
                        <p>Her kan du skrive noe tekst</p>
                        <a class="link" href="~/horse/riversidestar">Full story ...</a><img src="~/images/img01.jpg" width="900" height="350" alt="" /></div>
                    <div class="slide">
                        <h2>Riverside Star i naturen</h2>
                        <p>Her kan du skrive noe tekst</p>
                        <a class="link" href="~/horse/riversidestar">Full story ...</a><img src="~/images/img02.jpg" width="900" height="350" alt="" /></div>
                </div>
            </div>
            <div class="indicator">
                <ul>
                    <li class="active">1</li>
                    <li>2</li>
                </ul>
            </div>
        </div>
        <script type="text/javascript">//SOME SCRIPT</script>

    </div>
</div>

<div id="page">
    <div id="content">
         @RenderBody()

    </div>

    <div id="sidebar-bg">
        <div id="sidebar">
            <h2>Nyheter</h2>
            @{Html.RenderAction("ShortNewsList", "News");}
        </div>
    </div>

    <div style="clear: both;">&nbsp;</div>
</div>

Right now, its only the renderBody part that is different on each view. How can I change the content of the DIV with id=banner when I go into different View

When I try to add it in another View, it will off course be very wrong in the layout

  • 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-05T15:34:33+00:00Added an answer on June 5, 2026 at 3:34 pm

    You could use Razor sections. In your Layout define a section:

    @RenderSection("Banner", required: false)
    

    and in your view override this section:

    @section Banner {
        ... contents of the banner specific to that view
    }
    

    You could also define a default banner so that you don’t need to override in each view:

    @if (!IsSectionDefined("Banner"))
    {
        ... put the default banner contents here
    }
    else
    {
        @RenderSection("Banner", required: true)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a top-level _Layout.cshtml that looks something like this: <html> <head> @RenderSection(Header, required:
I have this code snippet in an email layout: <div> <?php echo $this->Html->image('Layouts/default/Logo.png', array(
I have a base layout, BaseLayout.cshtml: <html> <body> @RenderBody() <div id=footer> @if (!IsSectionDefined(Footer)) {
I am using an mvc application and in _Layout.cshtml page I have some javascript
I have something like @{ Html.RenderPartial(@~/Views/Management/_Main.cshtml); } Can I change this view without page
I have some base layout with site structure. In this default layout I define
I created an area named Admin. In /Areas/Admin/Views/, I have _ViewStart.cshtml with this: @{
I have a MVC 3 project in which I use _Layout.cshtml as master page
In _Layout.cshtml I have the following defined in the tag: @RenderSection(JavaScript, required: false); The
I have _Layout.cshtml defined for my mvc application, which is shown below: @inherits System.Web.Mvc.WebViewPage

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.