【发布时间】:2014-05-14 09:15:13
【问题描述】:
我想根据用户是否登录有条件地隐藏EnumDropDownListFor 中的元素。
枚举
public enum SortType
{
[Display(ResourceType = typeof(NavigationItems), Name = "BestMatch")]
Best_Match = 0,
[Display(ResourceType = typeof(NavigationItems), Name = "Alphabetical")]
Alphabetical,
[Display(ResourceType = typeof(NavigationItems), Name = "PriceAsc")]
PriceAsc,
[Display(ResourceType = typeof(NavigationItems), Name = "PriceDesc")]
PriceDesc
}
我要隐藏的项目是PriceAsc & PriceDesc
我尝试查看 AutoGenerateFilter 和 AutoGenerateField 属性无济于事。
查看
@Html.EnumDropDownListFor(x => x.sortType, new { id = "orderResults" })
【问题讨论】:
-
如何取消 EnumDropDownListFor 并实现您自己的自定义帮助程序来检查 user.identity.isauthenticated?
-
这就是我以前会这样做的方式,我希望有一些不错的 MVC 5.1 方式来做到这一点:)
-
你可以在这里找到解决方案stackoverflow.com/questions/27133014/…
标签: c# asp.net asp.net-mvc asp.net-mvc-5