• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 13390
  • Last Modified:

Adjusting the height of a ListBox (<select>)

I'm using the ListBox on my HTML-page.

<select size="4" name="DrawingsList" id="DrawingsList" style="height:100%;width:100%;" >
  <option value="vvv" >TTT</option>

The ListBox is putted into a DIV and should cover all the space inside the DIV. But the height of the ListBox is automatically rounded and made divisible by the font's height. So, the height is a bit incorrect.

In WinForms and Win32, I know, you can turn off the "Integral height" mode and get exactly sized ListBox.

How can I get exactly sized ListBox in HTML?

Thanks for a response!
Alexey Fedorov
Alexey Fedorov
  • 3
1 Solution
Try using the ASP.NET ListBox control instead of the HTML equivalent - this should give you exact control over the size
My mistake - looks like in the designer you can set the size, but when you run it, it automatically resizes!
Alexey FedorovSoftware developerAuthor Commented:
Yes, I'm using
<asp:ListBox ID="DrawingsList" runat="server"  DataSourceID="SqlDrawings" DataTextField="AssemblyName" DataValueField="AssemblyId" AutoPostBack="True" CssClass="DrawingsListClass" Height="100%" Width="100%"></asp:ListBox>

I have tried to set the height by means of Width property of the asp:ListBox and by means of CSS. The result is the same: rounded "Integral height" is used.
Take a look at this:


I've just tried it out by creating a Custom Web Control using their technique and it seems to work! (In C#)
Forced accept.

EE Admin

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now