如何显示一个下拉列表在asp.net中的所有项目? [英] how to show all item of a dropdown list in asp.net?

查看:135
本文介绍了如何显示一个下拉列表在asp.net中的所有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想告诉所有的下拉列表中的的项目,因为它是开不点击向下箭头。你有什么建议吗?

I want to show all of the items of a dropdown list as it is opened without clicking the down arrow. Do you have any suggestions?

推荐答案

有很多方法可以做到这一点。

There's a lot of ways to do this.

最基本的方法如下:

<html>
    <head>
        <title>Example</title>
    </head>
    <body>

        <div style="float:left; width:100%; height:30px;">
            <select id="AutoDropdown" OnMouseOver="DoDropDown(this);" OnMouseOut="DoDropDown(this);">
                <option>Test1</option>
                <option>Test2</option>
                <option>Test3</option>
                <option>Test4</option>
            </select>
        </div>

        <div>
            <p>Here is some text that we hope the drop down list will appear over</p>
        </div>

        <script type="text/javascript">

        function DoDropDown(objSel){

             if(objSel.size > 1){
              objSel.size = 1;
              objSel.style.position='static';
             }
             else{
              objSel.size = objSel.options.length;
              objSel.style.position='absolute';
              objSel.style.height='auto';
            }
        }

        </script>

    </body>
</html>

这模拟的效果,我认为你正在努力实现的,但看起来并不大。

This emulates the effect I think you are trying to achieve but doesn't look great.

您可以得到更好的效果通过模拟一个下拉列表 - 有大量的在网络上控制的替代品

You can get a better effect by emulating a drop down list - there are plenty of control alternatives on the web.

有一个Silverlight版本在这里:

There's a Silverlight version here:

HTTP://gallery.ex$p$pssion.microsoft.com/OpenComboBoxDropDown

还有各种控件,你可以在AJAX工具包适应:

There's also a variety of controls you could adapt in the AJAX toolkit:

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite

我是pretty的肯定,你可以使双方的下拉列表和PopupControls出现在鼠标悬停事件。

I'm pretty sure you can make both the DropDown and PopupControls appear on a MouseOver event.

随着PopupControl,绑到一个文本框,当用户选择一个值,填充文本框。

With the PopupControl, tie it to a text box, and when the user selects a value, populate the text box.

一些第三方控件(如Telerik的)也支持这种风格。

Some of the third party controls (like Telerik's) also support this style.

这篇关于如何显示一个下拉列表在asp.net中的所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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