C# – DropDownList width in Internet Explorer

asp.netc++internet-explorer

I have an ASP.NET DropDownList with a rather wide content, while the closed list's width has to be quite small due to room limitations on the site. That's why I need to be able to set a specific width to the list when it's closed, but want it to be as wide as the content when it's opened.

By default, Firefox automatically makes DropDownLists as wide as its content when opened. Internet Explorer on the other hand does not.

Is there any way to tell IE to make the opened DDL as wide as the content when it's opened, but have it in a smaller size when closed? Preferably without using javascript.

EDIT: Ok, I wasn't clear enough in my first post. The emphasis is on when opened. I want a specific width on the list when it's closed, but I want it to be as wide as the content when opened. As I said, Firefox does this, IE does not.

Best Solution

I'd recommend not using the drop down list, but a more javascript friendly one like this

http://jquery.sanchezsalvador.com/samples/example.htm

This will allow your content to expand past the selects width.