Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to control DropDownList length ?

Posted on 2002-07-08
6
Medium Priority
?
1,082 Views
Last Modified: 2008-01-16
I have created a DropDownList Web Control with all 50 states in the list.

When the drop-down button is clicked, the drop-down list goes all the way to the top or bottom of the page with a scroll bar.

How do I limit the drop-down list to 10 items with a scroll bar to see more?
0
Comment
Question by:12NoVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7139478
Just add "size" attribute to your drop down control list.
For example to show only 2 items and scroll bar for rest. you can use folowing sample of code.

MyListBox.Attributes.Add("size", "2");
0
 

Author Comment

by:12NoVB
ID: 7139608
Thanks naveenkohli... Almost...

I placed your suggestion in the server side script (VB.NET).  The DropDownList turned into a ListBox (no more drop-down) of the proper size.  I would still like to have a drop-down box.

I am having a hard time finding a good reference for the "Attributes" property in MSDN.  I take it that this is a CSS attribute.  Can you point me to a good reference or list for different styles and related objects?

Thanks,
Rich



0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 7141326
DropdownList control renders <select> HTML tag. So whatever attributes and styles apply to <select> tag, the same can be added to Attribute propperty of DropdownList control. The behavior you are seeing after setting size=2 is what actuall <select> tag will do. ASP.Net control isnot doing anything special on its own.
The best reference for CSS or attribute would be MSDN. The only thing that you will ned to know is what ASP.Net control corresponds to which HTML tag.

Naveen
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:12NoVB
ID: 7141964
I continue to be unable to control the drop-down box size while maintaining the the drop-down box action.

Is there a straight foward way to control the <select> tag or DropDownList drop-box size while maintaining drop-down box action?  Please include an example in your answer.
0
 
LVL 23

Accepted Solution

by:
naveenkohli earned 400 total points
ID: 7143292
No there is no straight forward way .. The moment you add "size" attribute, the drop down action will disappear. This is how <select> tag works. You can try it yourself by adding a <select> tag on your page.
0
 

Author Comment

by:12NoVB
ID: 7143345
Thanks for the confirmation.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question