Asked by:
fixed width dropdownlist box

Question
-
User-107483765 posted
i need some help in writing a custom dropdownlist with fixed width.
I have lot of dropdown's on my form and they occupy lot of space (the lenght of the options are long).
<option> NEW YORK NORTHERN COMMUTER </option>
any help would be highly appreciated.
Monday, May 5, 2008 4:26 PM
All replies
-
User1873438307 posted
Hi,
Welcome to the ASP.NET forums
Just add the width attribute to your ddl tag
<asp:dropdownlist width="200px" . ...
HTH
Regards
Monday, May 5, 2008 5:37 PM -
User1191518856 posted
The DropDownList control exposes a Width property which you can set both in markup or in code-behind:
<asp:DropDownList ID="DropDownList1" runat="server" Width="300px"></asp:DropDownList>
Or you could use CSS to set it from code behind:
DropDownList1.Style.Add("width", "100px");
Monday, May 5, 2008 5:39 PM -
User-107483765 posted
i wanted to develop a control that would have a fixed length, but the list items should be able to show the whole description.
Monday, May 5, 2008 11:16 PM -
User597999960 posted
I have the same problem.
I.e If I do not set a width to the DDL the longest item determines the width. I need to set a shorter width, but still retain the dynamic width when the list is expanded.
Firefox seems to handle this by itself. IE is stubborn and just displays its list width the same as the control width.
Has anyone found a solution to this problem?
Sunday, August 31, 2008 10:39 PM -
User481221548 posted
Hi there
As you see, theres no native solution there.
You have to workaraound this with Javascript depending on the longest Item.Sunday, August 31, 2008 11:25 PM