lundi 8 avril 2019

Get custom attribute in razor view

I have DTO with fields and custom attributes for title of each field.

realization of attribute:

  public class TitleAttribute : System.Attribute
{
    public TitleAttribute()
    {
    }

    public TitleAttribute(string name)
    {
        Name = name;
    }

    public string Name { get; set; }
}

I use this custom attributes for my dto-fields, part of dto-code:

    [Title("Stage of sale*")]
    public string StageName { get; set; }

    [Title("Sum in currency Oppty")]
    public decimal Sum { get; set; }

    [Title("Currency")]
    public decimal Currency { get; set; }

I need to get titles of all fields and show it in my razor view (like table, for example). What should i do? Should i create extension method for my dto-class? any ideas? thank you





Aucun commentaire:

Enregistrer un commentaire