4
在ASP.NET MVC 3中使用RenderSection助手时,是否可以测试是否存在提供的内容部分?如何测试内容部分是否在ASP.NET MVC 3的RenderSection中提供3
例如:
@RenderSection("RightCrumbContentArea", required: false)
如果上述不被供应,我希望生成一些其他内容。
在ASP.NET MVC 3中使用RenderSection助手时,是否可以测试是否存在提供的内容部分?如何测试内容部分是否在ASP.NET MVC 3的RenderSection中提供3
例如:
@RenderSection("RightCrumbContentArea", required: false)
如果上述不被供应,我希望生成一些其他内容。
据我所知,这是可能的。
试试下面的代码:
@if (IsSectionDefined("RightCrumbContentArea")) {
@RenderSection("RightCrumbContentArea")
} else {
<span>poo</span>
}