473,549 Members | 2,573 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!

..DynamicListbo x
{
min-width:100px;
width:100%;
}

<table>
<tr vAlign="top">
<td>
<asp:listbox id="m_lbxFieldM appings" runat="server"
Rows="12" CssClass="Dynam icListbox"></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_btnMoveDo wn" Text="Move Down"
Runat="server" CssClass="btn" Width="85px"></asp:button>
</p>
<p>
<asp:button id="m_btnAddFie ldMap" Text="Add Field Map"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFi eldMap" Text="Edit Basics"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFi eldMapFields" Text="Edit Fields"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<br>
<br>
<asp:button id="m_btnDelete FieldMap" Text="Delete" Runat="server"
CssClass="btnCr itical" Width="85px"></asp:button>
</p>
</td>
</tr>
</table>

Thanks again for your time and expertise, Cam

Oct 31 '07 #1
2 3916
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_lbxFieldM appings" runat="server"
Rows="12" CssClass="Dynam icListbox"></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_btnMoveDo wn" Text="Move Down"
Runat="server" CssClass="btn" Width="85px"></asp:button>
</p>
<p>
<asp:button id="m_btnAddFie ldMap" Text="Add Field Map"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFi eldMap" Text="Edit Basics"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<asp:button id="m_btnEditFi eldMapFields" Text="Edit Fields"
Runat="server" CssClass="btn" Width="85px"></asp:button>
<br>
<br>
<br>
<asp:button id="m_btnDelete FieldMap" Text="Delete" Runat="server"
CssClass="btnCr itical" 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
2513
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. Amazingly I have managed to display the table - no problem, I can select rows - no problem, BUT I can't work out how to display more than one of the...
1
8360
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 I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's...
6
2862
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 a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access...
1
9855
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 work. Thanks ahead.
5
3026
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 simple code to create a graph in an existing php page. I added the code for the graph and added the elements of it plus some static data. However,...
0
3482
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 to white the used CSS to set the opacity to 90 so that you can see the background image through the table. The problem I am having is with the...
7
1935
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 and the next and previous buttons are added again and again. Please help meto solve the problem. The full html and javascript are attached for your...
2
1799
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 table? I want the div to normally be centered and 90% of the page width. The table content is dynamic so I never know how wide it's going to be. I...
2
3001
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 local system that validations work.plz tell that whats the problem in that. Here is my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7459
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7726
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7485
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7819
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5377
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1953
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.