Model view controller 如何在MVC的DropDownList中添加占位符

Model view controller 如何在MVC的DropDownList中添加占位符,model-view-controller,Model View Controller,我正在尝试使用下拉列表中的占位符,但它不起作用。请帮助了解如何在下拉列表中添加占位符: @Html.DropDownList("Category", ViewData["Category"] as IEnumerable<SelectListItem>, new { @class="flexselect form-control" ,@placeholder="---Select---"}) @Html.DropDownList(“Category”,ViewData[“Cate

我正在尝试使用下拉列表中的占位符,但它不起作用。请帮助了解如何在下拉列表中添加占位符:

@Html.DropDownList("Category", ViewData["Category"] as IEnumerable<SelectListItem>, new { @class="flexselect form-control" ,@placeholder="---Select---"}) 
@Html.DropDownList(“Category”,ViewData[“Category”]作为IEnumerable,新的{@class=“flexselect form control”,@placeholder=“---选择----”})

首先对于
占位符
您不需要在其开头使用
@
,“@”仅适用于
。对于
DropDownList
设置默认文本:

@Html.DropDownList("Category", ViewData["Category"] as IEnumerable<SelectListItem>, "---Select---", new { @class="flexselect form-control"})
@Html.DropDownList(“Category”,ViewData[“Category”]作为IEnumerable,“--Select--”,new{@class=“flexselect form control”})

您使用的是哪种框架?asp.net还是别的什么?请给我们正确的标签。