【问题标题】:Default Text not displayed in Chosen (JQuery) DropDownList选择的(JQuery)DropDownList 中未显示默认文本
【发布时间】:2012-06-15 10:10:07
【问题描述】:

我正在为 ASP.NET MVC (Razor) 项目使用 Chosen JQuery 插件。对于下拉列表,它不显示由data_placeholder 设置的默认文本值,而是显示列表的第一项。

<div class="editor-field">
    @Html.DropDownList("AuthorId", (IEnumerable<SelectListItem>)ViewBag.AuthorId, new
    {
        @class = "chzn-dropdown",
        data_placeholder = "Select Author...",
        style = "width:270px;"
    })
    @Html.ValidationMessageFor(model => model.Author)
</div>

如何显示下拉列表的默认文本?

【问题讨论】:

    标签: razor jquery-chosen


    【解决方案1】:

    答案在所选网站上

    注意:在单选时,假定第一个元素被浏览器选中。要利用默认文本支持,您需要包含一个空白选项作为选择列表的第一个元素。

    【讨论】:

    • 感谢您的回答...我没有在网站上看到它:)
    猜你喜欢
    • 2019-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 2011-03-17
    • 2013-10-19
    • 1970-01-01
    相关资源
    最近更新 更多