JonH JonH - 18 days ago 5
ASP.NET (C#) Question

chosen data-placeholder doesn't display fully for listboxes

I have an asp.net 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

Region
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 asp.net 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...">
</asp:ListBox>


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

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

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

Answer

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.

Comments