Ponomarenko Igor
Ponomarenko Igor

Reputation: 31

ASP.NET Display Name attribute wrong encoding

Could you help me with next issue.

I have model, generated by Entity Framework, and when I try to use attribute [Display(Name="Місто")] in View, I see next "Íàçâà ì³ñòà" (cp1252). But when I create custom model and use the same attribute, all works well.

My custom Model:

    public class Cities
{
    public int Id { get; set; }
    [Display(Name = "Місто")]
    public string Name { get; set; }
}

Works well, in html show:

<label class="control-label col-md-2" for="Name">Місто</label>

Model generated by Entity Framework

    public partial class City
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public City()
    {
        this.Patients = new HashSet<Patient>();
        this.Patients1 = new HashSet<Patient>();
    }

    public int Id { get; set; }
    [Display(Name="Місто")]
    public string Name { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<Patient> Patients { get; set; }
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<Patient> Patients1 { get; set; }
}

Doesn't work, in html show:

<label class="control-label col-md-2" for="Name">&#204;&#179;&#241;&#242;&#238;</label>

Can you give me any advise? Thank you.

Upvotes: 1

Views: 996

Answers (1)

Ponomarenko Igor
Ponomarenko Igor

Reputation: 31

The problem solved, I'm just opened generated file with model in Notepad++ and encoded to utf-8

Upvotes: 2

Related Questions