Solved

How to control DropDownList length ?

Posted on 2002-07-08
6
1,069 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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
Help with error when uploading excel file 3 29
Need to start a web service from Visual Studio 2015 Pro 2 24
start a process from a service 3 23
Expression Evaluater 3 26
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

809 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