Html helper to show display name attribute without label

Posted by Pedre on Stack Overflow See other posts from Stack Overflow or by Pedre
Published on 2012-07-12T08:25:16Z Indexed on 2013/10/20 3:54 UTC
Read the original article Hit count: 504

Filed under:
|
|
|

I have this:

[Display(Name = "Empresa")]
public string Company{ get; set; }

In my aspx I have:

<th><%: Html.LabelFor(model => model.Company)%></th>

And this generates:

<th><label for="Company">Empresa</label></th>

Are there any html helper extensions to only show the display attribute without label, only plain text? My desired output is this:

<th>Empresa</th>

Thanks!

EDIT

I tried DisplayFor or DisplayTextFor as suggested, but they are not valid because they generate:

<th>Amazon</th> 

They return the value of the property... I want the name from the Display attribute.

© Stack Overflow or respective owner

Related posts about c#

Related posts about html