Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net mvc how to change the default label text in @html.labelfor

So using annotations my default label for a field is [Display(Name = "Spent")]

But of course depending on the context the field is displayed in I would like to change it in the View to say "Spent $".

For the label, MVC5 scaffolding generates... @Html.LabelFor(model => model.Spend Amount, htmlAttributes: new { @class = "control-label col-md-2" })

and so the label is "Spent".

How can I make it "Spent $" in the view..??

like image 614
ThomasAJ Avatar asked Jul 07 '14 07:07

ThomasAJ


1 Answers

Use this overloaded LabelFor method

@Html.LabelFor(model => model.SpendAmount, "Spent $", htmlAttributes: new { @class = "control-label col-md-2" })
like image 189
AliRıza Adıyahşi Avatar answered Oct 16 '22 14:10

AliRıza Adıyahşi