In a DTO object I'd like to hard code the label description for the rendered html text box so that I can have an html helper function like TextBoxWithLabel where I pass only the object and it automatically creates the label taken from the description attributes.
public class MessageDTO
{
public int id { get; set; }
[Description("Insert the title")]
public string Title { get; set; }
[Description("Description")]
public string Body { get; set; }
}
Then in my view page I would like to call:
<%=Html.TextBoxWithLabel<string>(dto.Title)%>
and get the in the rendered view
<label for="Title">Insert the title :</label>
<input id="Title" type="text" value="" name="Title"/>
I think to achieve this I should use reflection. Is it correct or it will slow down the view rendering?