MVC Controller parameter for a form element with a dot in it?

前端 未结 3 1937
孤城傲影
孤城傲影 2021-02-19 18:45

If you\'re using the Html.TextBoxFor() type methods, you may well end up with Form controls that have dots in their names, like this:

3条回答
  •  执笔经年
    2021-02-19 19:10

    I have found another way, a kind of hack because I believe this is misuse of BindAttribute, to associate firstName parameter with Contact.FirstName input element:

    [HttpPost]
    public ActionResult FooAction([Bind(Prefix="Contact.FirstName")]string firstName)
    

    This for sure works with ASP.NET MVC 1.

提交回复
热议问题