Solved

How to control DropDownList length ?

Posted on 2002-07-08
6
1,066 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
  • 3
  • 3
6 Comments
 
LVL 23

Expert Comment

by:naveenkohli
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:12NoVB
Comment Utility
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 100 total points
Comment Utility
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
Comment Utility
Thanks for the confirmation.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now