Click here to Skip to main content
11,804,574 members (76,285 online)
Rate this: bad
Please Sign up or sign in to vote.
<asp:ListBox ID="lboxCategory" runat="server" AutoPostBack="True" align="left"
                    onselectedindexchanged="lboxCategory_SelectedIndexChanged" BackColor="#33CCFF"
                     Height="100%" Width="100%">
Posted 16-Apr-13 1:48am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


You can specify the value for rows attribute (HTML size) same as the number of actual option elements (HTML select_control.length) in the list (ASP.NET Iterms.Count). You can also do it in Javascript. Following snippet shows how it can be done on client side using JavaScript.
<!DOCTYPE html>
window.onload = function() {
   var lst = document.getElementById('mylist');
   lst.size = lst.length;
<select id="mylist">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
  <option value="ferrari">Ferrari</option>
  <option value="swift">Swift</option>
  <option value="etios">Etios</option>
Amirsalgar1 at 16-Apr-13 8:12am
thanks for reply sir i got a property
ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden"

but dont know how to implement it in my code
Prasad Khandekar at 16-Apr-13 8:24am
No need of this property use Rows property and set it's value to Items.Count. For HTML select the default value of size attribute is 1 which results in a combobox being rendered. Setting it to a value greater than 1 results in ListBox being rendered. In your case since you don;t want to display the vertical scrollbar the value of size attribute should be equal to the number of items being displayed in the select which is nothing but the select_control.length.

Prasad Khandekar at 16-Apr-13 8:38am
Scrollviewer is a windows control.
Amirsalgar1 at 16-Apr-13 8:42am
Amirsalgar1 at 16-Apr-13 8:26am
i have add your code in my project but the scroll bar property is still there
Amirsalgar1 at 16-Apr-13 8:28am
can you join me on team viewer so that you will come to know which problems i am facing
Amirsalgar1 at 16-Apr-13 8:30am
175 735 453
Prasad Khandekar at 16-Apr-13 8:31am
I am afraid I will not be able to do so from within my office network. Have you tried running the HTML code?
Amirsalgar1 at 16-Apr-13 8:33am
ohh okay then please tell me the time when you will free ,i will be there that time
Prasad Khandekar at 16-Apr-13 8:40am
Ok will post a reply here. Will be late though around 10:30 PM.
Amirsalgar1 at 16-Apr-13 8:42am
okay thank you sir , i ll be here sharp 10.30
Amirsalgar1 at 16-Apr-13 8:36am
you i had tried
Amirsalgar1 at 16-Apr-13 13:27pm
u there sir?
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

with below small css trick hope u can do that
<style type="text/css">
        .css-lb {
            .css-lb select {
            .css-lb option {
<div class="css-lb">
           <asp:listbox id="ListBox1" runat="server">
                <asp:listitem text="text1" />
                <asp:listitem text="text2" />
                <asp:listitem text="text1" />
                <asp:listitem text="text2" />
               <asp:listitem text="text1" />
                <asp:listitem text="text2" />
               <asp:listitem text="text1" />
                <asp:listitem text="text2" />
               <asp:listitem text="text1" />
                <asp:listitem text="text2" />

worked for me hope it will help u out
Amirsalgar1 at 16-Apr-13 13:37pm
yup it works for me too..thanks a lot sir ..
Prasad Khandekar at 16-Apr-13 15:10pm
This solution will work as long as sum of height of all the items in a list does not exceeds 500px and width of an option is less tah 100px . After that div will partially hide the listbox (height/width)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 3,205
1 Maciej Los 1,950
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,187

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100