gpt4 book ai didi

asp.net - 是否可以对具有强类型资源的LabelFor,ValidationMessageFor,EditorFor使用数据注释?

转载 作者:行者123 更新时间:2023-12-04 18:16:33 26 4
gpt4 key购买 nike

我想在我的ASP.NET MVC应用程序中使用DataAnnotations。我已强类型化资源类,并想在我的 View 模型中定义:

[DisplayName(CTRes.UserName)]
string Username;
CTRes是我的资源,是自动生成的类。上面的定义是不允许的。还有其他解决方案吗?

最佳答案

属性无法做到这一点

C# attribute text from resource file?

Resource.ResourceName将是一个字符串属性,属性参数只能是常量,枚举,typeofs

关于asp.net - 是否可以对具有强类型资源的LabelFor,ValidationMessageFor,EditorFor使用数据注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2345501/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com