Reputation: 1497
I have Two Layouts, MainLayout
and
SubLayout
.
SubLayout
inherits from MainLayout
.
In MainLayout`I have Section Like this :
<ul>
@RenderSection("LostSection",true)
</ul>
And in SubLayout
have :
<div id="main-content">
@RenderBody()
</div>
@section LostSection{
@{Html.RenderAction(MVC.Home.ActionNames.NewFind, MVC.Home.Name)}
}
and my Action is :
[ChildActionOnly]
public virtual ActionResult NewFind()
{
var things = _things.NewThings(ThingType.Found).Select(x => new LastThingViewModel {HasReward=x.IsReward,Id=x.Id,Reward=x.Reward,Title=x.Title});
return PartialView(MVC.Partials.Views._NewFound,things);
}
But when I run the project I get this error:
Section not defined: "LostSection"
And my other views inherits SubLayout
.
Thanks for help.
Upvotes: 1
Views: 229
Reputation: 11544
Add below line to SubLayout
:
@section Header {@RenderSection("LostSection", true)}
More info: In MVC Razor, how do you do a RenderSection defined below a sub-layout?
Upvotes: 1