473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with Listbox having dynamic content with a minimum width

Hello Everyone, I am having problems with a listbox control. I have a
page with a couple of labels and drop-down lists at the top, and then
below there is a table with two columns, the first column contains a
listbox and the second column contains some buttons. I am trying to
display it such that if the listbox is empty it will be at least 100px
wide, but if there is content in the box I want it to expand
dynamically such that if the content is 200px wide the listbox will
expand to show all the content. I have tried using the min-width style
property without any success.

The following is the code from the table portion of my page, I have
included the css class used for the listbox. For some reason in IE7
the minimum width is getting ignored, In fact the listbox is given the
same width of the column, which in this case isn't set so it is
defaulting to 0! In firefox the listbox has a minimum width of 100px
when there is no content, and it expands to the width of the content
if it is bigger, so it works as expected! any suggestions on how to
get this to work in IE7(or even IE6) or any links to some good CSS
tutorials would be greatly appreciated!

..DynamicListbox
{
min-width:100px;
width:100%;
}

<table>
<tr vAlign="top">
<td>
<asp:listbox id="m_lbxFieldMappings" runat="server"
Rows="12" CssClass="DynamicListbox"></asp:listbox>
</td>
<td vAlign="top">
<p>
<asp:button id="m_btnMoveUp" Text="Move Up"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnMoveDown" Text="Move Down"
Runat="server" CssClass="btn" Width="85px"></asp:button>
</p>
<p>
<asp:button id="m_btnAddFieldMap" Text="Add Field Map"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFieldMap" Text="Edit Basics"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFieldMapFields" Text="Edit Fields"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<br>
<br>
<asp:button id="m_btnDeleteFieldMap" Text="Delete" Runat="server"
CssClass="btnCritical" Width="85px"></asp:button>
</p>
</td>
</tr>
</table>

Thanks again for your time and expertise, Cam

Oct 31 '07 #1
2 3895
you need two classes, one for empty and one for data.
-- bruce (sqlwork.com)
cs***@tarasoft.com wrote:
Hello Everyone, I am having problems with a listbox control. I have a
page with a couple of labels and drop-down lists at the top, and then
below there is a table with two columns, the first column contains a
listbox and the second column contains some buttons. I am trying to
display it such that if the listbox is empty it will be at least 100px
wide, but if there is content in the box I want it to expand
dynamically such that if the content is 200px wide the listbox will
expand to show all the content. I have tried using the min-width style
property without any success.

The following is the code from the table portion of my page, I have
included the css class used for the listbox. For some reason in IE7
the minimum width is getting ignored, In fact the listbox is given the
same width of the column, which in this case isn't set so it is
defaulting to 0! In firefox the listbox has a minimum width of 100px
when there is no content, and it expands to the width of the content
if it is bigger, so it works as expected! any suggestions on how to
get this to work in IE7(or even IE6) or any links to some good CSS
tutorials would be greatly appreciated!

.DynamicListbox
{
min-width:100px;
width:100%;
}

<table>
<tr vAlign="top">
<td>
<asp:listbox id="m_lbxFieldMappings" runat="server"
Rows="12" CssClass="DynamicListbox"></asp:listbox>
</td>
<td vAlign="top">
<p>
<asp:button id="m_btnMoveUp" Text="Move Up"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnMoveDown" Text="Move Down"
Runat="server" CssClass="btn" Width="85px"></asp:button>
</p>
<p>
<asp:button id="m_btnAddFieldMap" Text="Add Field Map"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFieldMap" Text="Edit Basics"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFieldMapFields" Text="Edit Fields"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<br>
<br>
<asp:button id="m_btnDeleteFieldMap" Text="Delete" Runat="server"
CssClass="btnCritical" Width="85px"></asp:button>
</p>
</td>
</tr>
</table>

Thanks again for your time and expertise, Cam
Oct 31 '07 #2
Cam
On Oct 31, 9:02 am, bruce barker <nos...@nospam.comwrote:
you need two classes, one for empty and one for data.

-- bruce (sqlwork.com)
Thanks for your response Bruce,
Are you suggesting that I use two CSS classes, and then set the CSS
class depending on the content? If that is the case it would be just
as easy to set the width after checking for content, I could then set
Width=100px if there is no content and then set Width=Auto if there is
content. However this would require a major code change because these
listboxes are used on 30 different pages throughout my app and I would
have to make the same change to the binding method on each page.

I am asking if there is a way to use the min-width attribute that is
allegedly supported by IE7, or some other way to have the page act as
though the listbox has a minimum width. In the past I have used a 2X2
table with a div in the second row and the same column as the listbox.
The div is set with a width of 100px, and the listbox in the above row
has a width of 100%. The listbox will then be at least 100px because
of the div in the lower row, and in firefox the listbox will expand to
the width of the content if it is greater than 100px, however in IE
the width always stays at 100px, no matter what the content is.

Is there a way to get the min-width style attribute working in IE7 or
possibly another work-around like I had mentioned above to simulate a
minimum width that won't need a change to the C# code, but rather just
to the HTML?

Oct 31 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joe Bloggs | last post by:
I am trying display the contents of a table in a web page, select certain rows from that table and then display the fields that I have selected (now table columns) as text in a Label object....
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't...
5
by: Shawn Hamzee | last post by:
Hello All, I am having a problem with Image_Graph on php 5.1.4. I installed the package and all of its dependencies through pear installer without any hitches. Then I started to add some very...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
7
by: raknin | last post by:
Hi I have a carousel script. I want to load the carousel with a new set of pictures every time I press a button. The problem that I have that the script append the new pictures to the olds one...
2
by: j055 | last post by:
Hi The following HTML shows a table with some wide content which overlaps an outer div when the browser width is narrowed? How do I allow the table content to push the div to the width of the...
2
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.