Scrollbar in checkbox list in asp.net

Dr. Rajesh Rolen picture Dr. Rajesh Rolen · May 12, 2010 · Viewed 14.5k times · Source

i am using VS 2005, in asp.net please tell me how can i show scroll bar in checkboxlist after the number of item count goes beyond the specified. like my situation that if their exist more then 5 items in my checkbox list than it should show a scroll bar.. and i dont want to fix its height like if their is only 1 item than it should take space of 1 item only.... please help me...

i have used this but its taking space (Hight) even their is 1 or 2 items in list.. div style="overflow-y :auto; height :100px "

Answer

Artiom Chilaru picture Artiom Chilaru · May 12, 2010

Instead of fixing the height with a static value, you can set the max-height of the container div. In this case it will use auto height as long as it's less than the height you specified :)

P.S. To make the max-height cross-browser compatible, you have to set it as follows in your css:

.checkBoxList {
  max-height:100px;
  height:auto !important;
  height:100px;
}