2
When I create a field input-type-text
Via Razor, I do something like this:
@Html.TextBox("nomeTxt", null, new { @class = "form-control",
@placeholder = "Exemplo de placeholder",
@type = "text" })
When I want to add properties HTML That input, I put them as I did with the @class, @placeholder, @type
For example, if I want to put one MaxLength
, just add to the end, as in:
@Html.TextBox("nomeTxt", null, new { @class = "form-control",
@placeholder = "Exemplo de placeholder",
@type = "text",
@maxlength="10" })
However, some types of properties I can’t add that way. This is the case with data-date-format
. Razor can’t take these hyphens.
How could I create, via Razor, a input as the example below?
<input id="txtData" name="txtData"
placeholder="Ex.: 13/10/2019"
data-date-format="dd/mm/yyyy"
maxlength="10">
It worked perfect, thank you!
– Rafael