ASP.NET MVC 3: Override “name” attribute with TextBoxFor

前端 未结 11 1531
臣服心动
臣服心动 2020-11-28 05:41

Is it possible when using Html.TextBoxFor to override the name attribute?

I have tried with no success. I need to use TextBoxFor to get client side vali

11条回答
  •  一向
    一向 (楼主)
    2020-11-28 06:24

    Rob, actually there is a much simpler way. Instead of name, use Name:

    @Html.TextBoxFor(x => x.Data, new { Name = Model.Key + "_Data", id = Model.Key + "_Data" })
    

提交回复
热议问题