How to disable arrow buttons in asp.net razor mode?

In the column name of the model class public int? CTScore { get; set; }and in the Razor view, I want to use this as @Html.EditorFor(model => model.CTScore).

It appears as an editor window along with the up / down arrow buttons, but I do not need to show these spin buttons. How to do

Any help is appreciated.

+3
source share
2 answers

It looks like Razor is adding type="number"to the field input, which makes modern browsers display rotation buttons. If you want to disable this and use it instead type="text", you can add an attribute to the property DataType:

[DataType(DataType.Text)]
public int? CTScore { get; set; }
+4
source

The next line is what you need.

@Html.EditorFor(model => model.CTScore, new { htmlAttributes = new { @type="text" } })
+2
source

All Articles