Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET HTML VB.NET
<asp:ListBox ID="lboxCategory" runat="server" AutoPostBack="True" align="left"
 
                    onselectedindexchanged="lboxCategory_SelectedIndexChanged" BackColor="#33CCFF"
                     Height="100%" Width="100%">
                     </asp:ListBox>
Posted 16-Apr-13 2:48am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hello,
 
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>
<html>
<script>
window.onload = function() {
   var lst = document.getElementById('mylist');
   lst.size = lst.length;
  alert(lst.length);
}
</script>
<body>
<form>
<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>
</select>
</form>  
</body>
</html>
Regards
  Permalink  
Comments
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.
 
Regards,
Prasad Khandekar at 16-Apr-13 8:38am
   
Scrollviewer is a windows control.
Amirsalgar1 at 16-Apr-13 8:42am
   
okay
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
   
sir,
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
3611
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?
Regards,
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
good
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 {
            width:100px;
            overflow:hidden; 
            color:gray;
        }
            .css-lb select {
                border:none;
                height:500px;
            }
            .css-lb option {
                width:100px;
            }
    </style>
<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" />
            </asp:listbox>
        </div>
 
worked for me hope it will help u out
  Permalink  
v2
Comments
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 BillWoodruff 360
1 Mathew Soji 309
2 DamithSL 225
3 Afzaal Ahmad Zeeshan 202
4 Maciej Los 190
0 OriginalGriff 6,249
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 3,865


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 16 Apr 2013
Copyright © CodeProject, 1999-2014
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