JonH JonH - 1 year ago 69
ASP.NET (C#) Question

chosen data-placeholder doesn't display fully for listboxes

I have an listbox and I'm using the jquery chosen plugin.
The data-placeholder value doesn't seem to always work with list boxes.
For instance see the image:

enter image description here

Notice the list box for

it says "Select Re" then it stops...its quite random look at the list box for city that works fine. But look at the list box for country it is supposed to say
Select Country...
but it shows
Select Country..
(missing the last period). My listbox control's markup is as such:

<asp:ListBox ID="lbRegion" AutoPostBack="true" runat="server" class="chosen-select"
data-placeholder="Select Region..." SelectionMode="Multiple"
OnSelectedIndexChanged="lbRegion_OnSelectedIndexChanged" ToolTip="Select Region...">

I've tried re-creating it, etc...but to no avail. What gives?

Here's my jquery that includes the class for chosen:

search_contains: true,
no_results_text: "Oops, nothing found!",
allow_single_deselect: true
$('.chosen-container').css('width', '200px');

Answer Source

I noticed that each listbox on the page was given the class default. I am not saying this is a definite answer but it is a workaround. Simply add this to your jquery:

$(".default").css("width", "175px");

Use the width to your liking, in this case I used 175px.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download