DropDownListFor with a custom attribute with - in attribute name?

后端 未结 2 1134
遥遥无期
遥遥无期 2021-02-01 13:46

Question: I need to create a dropdownlist like this:


                        
    
提交评论

  • 2021-02-01 14:37

    Use an underscore instead

    @data_placeholder = "whatever"
    

    Since Mvc3 "_" is replaced with "-" when rendered. This applies to Mvc5 too.

    This works fine as underscores are not acceptable in attribute names in html.

    0 讨论(0)
  • 提交回复
    热议问题