When using Razor to add an input field, unwanted HTML attributes are included. The specific attribute causing the issue is value="0"
. It seems that Razor adds this attribute because the variable ccVersandkosten
is a float, which cannot be changed. Is there a way to prevent Razor from adding this attribute or remove it manually?
@Html.TextBoxFor(x => x.ccVersandkosten, new { @class = "form-control" })
I'm including an input field using Razor code.
<input class="form-control" data-val="true" data-val-number="Das Feld"Versandkosten" muss eine Zahl sein." data-val-required="Das Feld "Versandkosten"" value="0" id="ccVersandkosten" name="ccVersandkosten" type="text" />
The unnecessary attribute in my case is value="0"
, but I need the variable to remain as a float type.