如何处理ASP.NET中下拉列表控件中的长文本 [英] how to handle long text in dropdownlist control in ASP.NET

查看:192
本文介绍了如何处理ASP.NET中下拉列表控件中的长文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

对于太宽的下拉菜单项目的建议?

我有一个由数据库填充的下拉列表。其值字段包含记录的id,其选项字段包含记录的文本。但记录的文本条目非常长,使其下拉得很宽,完全改变了我的网页的外观。当我减少宽度时,它也会减少显示的文字。有没有什么办法可以使网页看起来不错,仍然允许用户看到全文(如包装,滚动或类似的东西)?

I have a drop down list which is populated by the database. Its value field contains the record's id, and its option field contains record's text. But the record's text entries are very long and make the drop down so wide that it totally changes the appearance of my webpage. When I cut down the width it also cuts down the text displayed. Is there any way I can make the web page look good and still allow the user to see the full text (like wrapping, scrolling, or something like that)?

如何我可以处理这个吗?

How can I handle this?

推荐答案

尝试使用CSS为您的下拉列表添加固定宽度,如:

Try using CSS to add a fixed width to your dropdown, like:

select {width: 150px}

虽然下拉列表本身将具有固定宽度,可能不会显示所有文本,但选项元素应扩展到最宽元素的宽度。

Whilst the dropdown itself will be of a fixed width and may not show all of the text, the option elements should expand to the width of the widest element.

在IE7及以下版本中可能无法使用,在这种情况下,此链接可能对这些浏览器有用:

May not work in IE7 and below, in which case the this link may be of some use for those browsers:

这篇关于如何处理ASP.NET中下拉列表控件中的长文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆