c# - How do i add vertical scroll bar in asp Dropdown list? -
my code
<asp:dropdownlist id="ddlfrom" runat="server" cssclass="from"></asp:dropdownlist>
and css code .from{ width:250px;height:25px}
height can not large because there large number of items in it. how add vertical scroll bar drop down ?
there few 3rd party controls out there in web, , bing them. put simple workaround involves dropdownextender (of ajax controltoolkit), textbox, listbox, , few lines of javascript.
here textbox hold selected value of listbox. aspx code below:
<asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> <asp:textbox id="textbox1" runat="server" text="select 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>
Comments
Post a Comment