In a popup template I am attempting to format decimal field to
- insert commas in the appropriate places
- show 2 decimal places
- show a $ sign when not editing the field.
I have the field decorated as follows
[DisplayName("Amount in $")]
[DisplayFormat(ApplyFormatInEditMode = false, DataFormatString = "{0:C2}")]
public decimal? CollateralAmount { get; set; }
I have tried 2 different approaches.
The below code does not give me any of the 3 things I need
<forminput asp-for="CollateralAmount" asp-format="{0:C2}"></forminput>
The below code gives me a text box with spinners that provides the decimal places I need and the commas in the correct place but I do not want spinners and it does not put a $ sign in when I am not editing the field.
<input type="number" class="currency" name="CollateralAmount" data-type="currency" data-bind="value:CollateralAmount" data-role="numerictextbox" />