Solved

How to control DropDownList length ?

Posted on 2002-07-08
6
1,070 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
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
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Please explain the parts of these 2 LINQ expressions 3 53
.NET 2008 VB and C# 6 39
VB.NET Textbox input validation 4 37
Where is this file? 3 25
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…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

840 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