数据属性有双引号

问题描述 投票:0回答:1

我正在使用 MVC,在我的班级中,我有一个成员,其描述中有双引号,如下所示:

[Display(Name = "Biological "Parent"?")]
public bool? IsParent { get; set; }

我们有什么方法可以使用上述方法在剃刀视图中显示双引号,还是我必须用我想要的内容声明标签?

我尝试将 (

"
) 替换为 (
"
),它在渲染时仅在标签文本中显示“
Biological "Parent"

asp.net-mvc-4
1个回答
0
投票

只需转义 C# 中的双引号即可:

[Display(Name = "Biological \"Parent\"?")]
public bool? IsParent { get; set; }

[Display(Name = @"Biological ""Parent""?")]
public bool? IsParent { get; set; }
© www.soinside.com 2019 - 2024. All rights reserved.