Last post Sep 03, 2020 05:35 PM by PatriceSc
Sep 03, 2020 01:58 PM|joegreen2005|LINK
How do I add ASCII character code for degree ° data annotation for Display. I tried this and it doesn't work. All I see is ° in the view when I use it in the @Html.LabelFor.
[Display(Name = "°C")]
Sep 03, 2020 03:06 PM|PatriceSc|LINK
And what happens with [Display(Name="°C")]; or do you mean you are saving your source code with an encoding that doesn't allow non ASCII characters ?
Sep 03, 2020 05:18 PM|joegreen2005|LINK
Yes [Display(Name="°C")] works but I'm wondering if there is a way to use ASCII code.
Sep 03, 2020 05:35 PM|PatriceSc|LINK
The problem is that this string is HTML encoded for you so that it shows exactly what you entered as a C# string ie if using °C<script> you'll see exactly that in your HTML page.
If using "View source" in your browser you'll see that to ensure that it has been encoded as &#176;C<script>