RenderSection()内的部分与母版页 [英] RenderSection() inside partial with master page

查看:817
本文介绍了RenderSection()内的部分与母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个局部的边栏添加到母版页(布局),并在这里面部分我使用:

I have a partial "Sidebar" added to the master page (Layout) and inside this partial I'm using:

@RenderSection("SearchList", required: false)

在的使用母版页我在做一个视图:

On one of the views that uses the master page I'm doing:

@section SearchList {
    // bunch of html
}

但它给我的错误:

but it's giving me the error:

文件〜/查看/共享/ _SideBar.cshtml不能直接要求,因为它所谓的IsSectionDefined的方法。

The file "~/Views/Shared/_SideBar.cshtml" cannot be requested directly because it calls the "IsSectionDefined" method.

什么是错在这里?

推荐答案

你所试图做的是不是目前在剃刀支持。部分只有查看页面和它的直接布局页面之间的工作。

What you are trying to do is not currently supported in Razor. Sections only work between the view page and its immediate layout page.

这篇关于RenderSection()内的部分与母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆