Solved

How to control DropDownList length ?

Posted on 2002-07-08
6
1,075 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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 100 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

726 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