如何添加在ASP下拉列表垂直滚动条? [英] How do i add vertical scroll bar in asp Dropdown list?

查看:425
本文介绍了如何添加在ASP下拉列表垂直滚动条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是

<asp:DropDownList ID="ddlFrom" runat="server" CssClass="From"></asp:DropDownList>                    

和我的CSS code是。从{宽度:250像素,高度:25px的}

and my css code is .From{ width:250px;height:25px}

高度不能如此之大,因为有大量的在里面的物品。
如何将垂直滚动条添加到我的下拉?

Height can not be so large because there are large number of items in it. How do I add a vertical scroll bar to my drop down ?

推荐答案

有一些第三方控件的网页在那里,你可以很容易BING他们。我只是把一个很简单的解决方法,涉及DropDownExtender(AJAX ControlToolkit的),文本框,列表框和Javascript几行。

There are a few 3rd party controls out there in the web, and you could easily bing them. I just put a very simple workaround that involves DropDownExtender (of AJAX ControlToolkit), TextBox, ListBox, and a few lines of Javascript.

下面文本框将举行ListBox的选定值。我的ASPX code以下:

Here TextBox will hold the selected value of the listbox. My ASPX code below:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="TextBox1" runat="server" Text="Select your item" CssClass="MyTextBox"></asp:TextBox>
            <div style="padding: 4px;" id="ItemsDiv" runat="server">
                <asp:ListBox ID="ListBox1" runat="server" onclick="callme()" CssClass="MyDropDown" Rows="6">
                </asp:ListBox>
            </div>
            <asp:DropDownExtender ID="DropDownExtender1" runat="server" TargetControlID="TextBox1"
                DropDownControlID="ItemsDiv">
            </asp:DropDownExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
<script>
   function callme() { 
           element = document.getElementById("ListBox1"); 
            str = element.options[element.selectedIndex].value; 
            document.getElementById("TextBox1").value = str; 
        } 
</script> 

这篇关于如何添加在ASP下拉列表垂直滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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