问题:我需要创建一个下拉列表,就像这样:
现在我可以像这样添加自定义属性:
<select id="ddCustomers" data-placeholder="Choose a customer" class="chzn-select" style="width:350px;" tabindex="1" multiple>
现在我可以像这样添加自定义属性:
@Html.DropDownListFor(m => m.Id, Model.Values, new { @disabled = "disabled" })
很遗憾,如果变量名中有“-”,则无法编译。
@Html.DropDownListFor(m => m.Id, Model.Values, new { @disabled = "disabled", @data-placeholder = "whatever" })
那么对于没有属性值的多个属性呢?
如果我传递一个字典或者NameValueCollection而不是new { @disabled = "disabled" }
,那么它会输出NameValueColletion/Dictionary的属性...
如何传递带有特殊字符的属性键?