Search code examples
asp.net-mvctabindexmvcrazor

TextBoxFor tabindex not rendering at all


I need to reorder the TAB key navigation and I am growing increasingly frustrated with how difficult it is to use tabindex. I need to modify the following to include tabindex

@Html.LabelFor(m => m.project_name)
@Html.TextBoxFor(m => m.project_name, new { @data_bind = "value: woheader_projectName" })
@Html.ValidationMessageFor(m => m.project_name)

I tried

@Html.LabelFor(m => m.project_name)
@Html.TextBoxFor(m => m.project_name, new { htmlAttributes = new { tabindex = "8" } }, new { @data_bind = "value: woheader_projectName" })
@Html.ValidationMessageFor(m => m.project_name)

As well as few other variations and I am getting errors.

Any ideas would be appreciated.


Solution

  • You need to combine all html attributes in the 2nd parameter

    @Html.TextBoxFor(m => m.project_name, new { tabindex = "8", data_bind = "value: woheader_projectName" })