【发布时间】:2017-09-06 06:16:09
【问题描述】:
我正在尝试在 Umbraco 中将 page 作为参数传递。在助手中,我需要页面的一些属性。比如名字,...
这是我的代码:
var PageWeAreInheritedFrom = CurrentPage;
@ShowBanner(PageWeAreInheritedFrom);
@helper ShowBanner(dynamic pageWeRIn)
{
if (pageWeRIn.bannerIsInherited)
{
@ShowBanner(pageWeRIn.Parent)
}
else
{
//here I want to have a switch case based on pageWeRIn.Name
//but I cant have it.
}
}
这是错误。似乎辅助方法中的页面类型不同
switch 表达式或 case 标签必须是 bool、char、string、 整数、枚举或对应的可空类型
【问题讨论】:
-
该错误可能意味着由于 pageWeRIn 是动态的,因此开关不知道 pageWeRIn.Name 是哪种数据类型。如果您尝试将 pageWeRIn.Name 放入字符串变量中,然后根据该变量进行切换呢?
-
@JannikAnker 不知道为什么它不能被包裹在字符串中
标签: razor helper umbraco7 current-page