Click here to Skip to main content
15,069,408 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<asp:ListBox ID="lboxCategory" runat="server" AutoPostBack="True" align="left"

                    onselectedindexchanged="lboxCategory_SelectedIndexChanged" BackColor="#33CCFF"
                     Height="100%" Width="100%">

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 16-Apr-13 13:37pm
yup it works for me too..thanks a lot sir ..
Prasad Khandekar 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)

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 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 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 16-Apr-13 8:38am
Scrollviewer is a windows control.
Amirsalgar1 16-Apr-13 8:42am
Amirsalgar1 16-Apr-13 8:26am
i have add your code in my project but the scroll bar property is still there
Amirsalgar1 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 16-Apr-13 8:30am
175 735 453
Prasad Khandekar 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 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 16-Apr-13 8:40am
Ok will post a reply here. Will be late though around 10:30 PM.
Amirsalgar1 16-Apr-13 8:42am
okay thank you sir , i ll be here sharp 10.30
Amirsalgar1 16-Apr-13 8:36am
you i had tried
Amirsalgar1 16-Apr-13 13:27pm
u there sir?

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900