asp.net-mvc-4

Data Attribute has double quote


I am using ASP.NET MVC and in my class I have member whose description has double quotes in it like below:

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

Is there any way we can use above method to display double quote in razor view or do I have to just declare label with what I want?

I tried replacing (") with (") and it just displays "Biological "Parent"" in label text when rendered


Solution

  • Just escape the double-quotes in C#:

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

    or

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