显示下拉列表中的前 n 个选项
考虑一个具有大量选项(例如 100 个选项)的 ASP.NET 服务器控件 DropDownList
(或 )。单击列表时,将显示 100 个选项的完整列表。它们全部显示出来,并跑出屏幕。
如何调整控件的选项列表大小或将其限制为前 n 个选项?
Consider an ASP.NET server control DropDownList
(or <input type='select'>
) with a large number of options (e.g. 100 options). When clicking on the list, the full list of 100 options are shown. They're all displayed, and run off the screen.
How can the control's picklist size be resized or limited to the first n options?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Frédéric Hamidi 已经给出了简短的答案,但他也向您推荐了一个完美的替代方案。 探索这一点,这与我遇到类似情况时所做的类似。
想法是你不要填充你的列表。这样,您的下拉菜单将是空的,取而代之的是您显示一个带有滚动条的
div
以及您想要的任何内容。以用户认为“这是下拉菜单”的方式对齐此div
。Frédéric Hamidi has already given the short answer, however he has also referred you to a perfect alternative. Explore this and that is similar to what I had done when I faced similar situation.
Idea is that you don't populate your list. This way your drop down will be empty and in place of that you show a
div
with scrollbar and whatever you wish. Align thisdiv
in such a way that user thinks, "it is the dropdown".