asp:dropdown list width

R

rum23

Is there a way to change the width of the dropdown list width? I don't want
to change the width of the dropdown control. This needs to be fixed width. I
only want to adjust the size of the drop down list of a combo box to fit the
size of the longest string in its items. How do I do this for asp:dropdown
control.

thanks.
 
N

Nathan Sokalski

Just use the CSS width property. The DropDownList automatically expands to
the width of the longest ListItem unless otherwise specified, so normally
you won't even need to do this. Am I somehow misunderstanding what you are
really trying to do? Good Luck!
 
R

rum23

thank you for responding, but this is not what I'm looking for.

I have to keep the widht of the combox box to a fixed width. I don't want to
change this fixed width at any time due to real estate on the page.

I want to increase the width of the List (this is the list that displays
when you click on the down arrow in the combo box). I want the width of this
list to be set to the longest item width.

In windows form, you can do this by simply setting the "ListWidth" property
for a comobox and I'm looking for something similar in asp web controls.

Please let me know if my question is not clear. Thanks much.
 
B

Brian Kenneth Nielsen

Hi there

If you want to make the dropdown more width, that the field that shows
the selected item.

Then you need to build the control your self.

The <select> will not do that for you.
Instead you have to make some good old DHTML. with an <input type=text
readonly>, that shows you the selected item. Then have a button with the
downarrow. This button must take the click event in javascript, and on
click show a <select> with multiple rows eg. 6 or 10 or what you deside.
When mouse moves out of this control, hide it.. if user selects an item,
then copy the item to the input field, and hide the control.

Hope you get the idea. In this way, you can have differente style for
<input> field, that shows the selected value, and the <select> which
only is visible, when the button is clicked.

Best regards and happy coding.
Brian Kenneth Nielsen
http://www.bknnet.dk/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top