question

RhettHerring-8289 avatar image
0 Votes"
RhettHerring-8289 asked RhettHerring-8289 answered

Display String Value to UpperCase

Working on ..net core 5 web site.

Model field
public string Rating { get; set; }

HTML display:
@Html.DisplayFor(modelItem => item.Rating)

I need to show the value to the user in uppercase only.

I have tried : @Html.DisplayFor(modelItem => item.Rating.ToUpper())

Which throughs an error "InvalidOperationException: Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions".

Is there an annotation I can use on the model?

How can I show the value as uppercase? Ideally not use css.




dotnet-entity-framework-core
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RhettHerring-8289 avatar image
0 Votes"
RhettHerring-8289 answered

This worked for me:

@Html.Encode(item.Rating).ToUpper()

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.