wertzui
wertzui

Reputation: 5740

ASP MVC non-breaking-space in Display attribute with DisplayNameFor

I have a model with a Property "Price" which has the DisplayAttribute

[Display(Name = "Price (in €)")]

Now i want to display this in a table header using

@Html.DisplayNameFor(model => model.Price)

But when the column is very small, the Text might be broken into two Lines:

Price (in
€)

But i want it to break this way:

Price
(in €)

Is it possible to insert a non breaking space into the Display attribute? Using "Price (in €)" results in the " " printed as Text.

Upvotes: 4

Views: 2107

Answers (1)

wertzui
wertzui

Reputation: 5740

Andrei posted the correct Answer in the comments: Non breaking space is a unicode character, with code 00a0. So this should work:

[Display(Name = "Price (in\u00a0€)")]

Upvotes: 6

Related Questions