I have a dropdownlist with 15datatypes,when i click the drop down it looks so clumsy ,can u suggest me how to put scroll in dropdownlist in asp.net
Asked
Active
Viewed 6,539 times
-1
-
what you have tried so far? – Sachin Sep 25 '13 at 10:15
-
possible duplicate of [Hide vertical scrollbar in – CodeCaster Sep 25 '13 at 10:15
-
Why not use `size=10` instead of a dropdown? – Abhitalks Sep 25 '13 at 10:20
-
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance. – dhein Sep 25 '13 at 10:25
3 Answers
1
I think you want this:
<asp:DropDownList ID="ddl" width="100px" onclick="this.size=1;" onMouseOver="this.size=5;" onMouseOut="this.size=1;" style="position:absolute;" runat="server">
<asp:ListItem>TextTextText1</asp:ListItem>
<asp:ListItem>TextTextText2</asp:ListItem>
<asp:ListItem>TextTextText3</asp:ListItem>
<asp:ListItem>TextTextText4</asp:ListItem>
<asp:ListItem>TextTextText5</asp:ListItem>
<asp:ListItem>TextTextText6</asp:ListItem>
<asp:ListItem>TextTextText7</asp:ListItem>
<asp:ListItem>TextTextText8</asp:ListItem>
<asp:ListItem>TextTextText9</asp:ListItem>
<asp:ListItem>TextTextText10</asp:ListItem>
<asp:ListItem>TextTextText11</asp:ListItem>
</asp:DropDownList>
Bip
- 697
- 2
- 10
- 29
-
IT is working but problem with this In listview i have a dropdowncolumn it is not adjusting in listview cell – Karthik Sep 25 '13 at 11:46
0
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>
else follow this link:
or http://forums.asp.net/t/1905270.aspx?DropDownList+Scroll+Bars
choudhury smrutiranjan parida
- 2,588
- 5
- 28
- 39
-
It's DropDownExtender and it fulfill ur need. u can follow the first link i mentioned to have a good idea. – choudhury smrutiranjan parida Sep 25 '13 at 10:37
-
pls follow this : http://blogs.msdn.com/b/rakkimk/archive/2011/05/02/dropdownlist-html-select-vertical-scrollbar-number-of-items.aspx – choudhury smrutiranjan parida Sep 25 '13 at 12:50
0
Try to use below code.
<asp:DropDownList runat="server" ID="ddlColors" onmousedown="this.size=5;" >
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Yellow</asp:ListItem>
<asp:ListItem>White</asp:ListItem>
<asp:ListItem>Black</asp:ListItem>
<asp:ListItem>Purple</asp:ListItem>
<asp:ListItem>no color</asp:ListItem>
</asp:DropDownList>
Or you could use CSS's overflow property in combination with the height property on the drop down menu to add a scrollbar.
.dropmenudiv
{
height: 300px;
max-height: 300px;
overflow-y: scroll;
}
Umm E Habiba Siddiqui
- 594
- 7
- 35
-
when i use onmousedown the size of dropdownbox became large and showing 5 items at atime – Karthik Sep 25 '13 at 10:22
-