Can I change the html name generated by Html.DropDownListFor?

前端 未结 9 1609
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-05 03:04

IDI am using the following code to create a drop down list:

 @for (var index = 0; index < Model.AdminSummaries.Count(); index++) 
            { 
            &         


        
9条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 03:37

    For those wondering why this doesn't work, the whole thing is case sensitive and need an @ in front of it...

    so, this works:

    new { @id = "myID", @Name = "myName", @Value = "myValue", @class = "form-control", @onchange = "javascript:DoSomething(this.value);" }
    

    And this doesn't (mind the lowercase 'n' in @name)

    new { @id = "myID", @name = "myName", @Value = "myValue", @class = "form-control", @onchange = "javascript:DoSomething(this.value);" }
    

提交回复
热议问题