Cut off SELECT

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hhi,

I'm working on an asp .net project that have small side panel which
'disallow' long SELECT/dropdown list.. So i could not force them to a certain
that shows my longest option, which now most of my option was being
'cut-off' half way, not able to show to full text..

Is there any way I could do some thing like in e Mozilla FireFox (as
currently using IE), which 'opens' e dropdown list when being click and shows
e full text that is longer than e defined width..

Million thanx in advance..
 
Place a div around dropdown set the width of the dropdown is 100% and
restrict the width of div to your side bar... in style of div set show scroll
auto...this can resolve the situation or you can use some 3rd party like
infragistics
 
Thanx for ur reply..

But this is not some thing that I wanted to do.. I tried your suggestion,
this method puts the whole dropdownlist into e DIV, which ended scrolling the
whole dropdownlist while the text is still 'cut-off' half way..

Or is there any way for me to add a Tooltip into each option of e
dropdownlist? So as when user mouseover then show the full-text of e selected
option in e Tooltip.. Had did some research online and found out that 'title'
don't work on IE.. but most of my users will be using IE..

Like to do some thing like our Windows taskbar (thru it is a 'drop-up'
list), for each of e items in e drop-up list there will be a Tooltip
available when mouseover. This Tooltip will show the full-text of e item
being mouseover..

Is there any way that I could do this??
Thanx again..
 
title does work in IE... however I cannot find a way to add the title
attribute to each option in a databound dropdownlist. I'm trying to find this
information for myself also, I posted a question on this newsgroup yesterday
about this topic.

If you happen to find the solution could you please let me know... I'll do
the same.

Gav
 
Found a solution....

You cannot add attributes to ListItems!! so heres how I got around it...
don't use asp:DropDownList!! Let me explain:

Instead use HTML select and a repeater to fill the select;

in aspx page
<select>
<asp:Repeater ID="rptListItems" Runat="server">
<ItemTemplate>
<option value='<%# DataBinder.Eval(Container.DataItem,
"DBItemValue") %>' title='<%# DataBinder.Eval(Container.DataItem,
"DBItemFullDesc") %>'><%# DataBinder.Eval(Container.DataItem,
"DBItemShortDesc") %></option>
</ItemTemplate>
</asp:Repeater>
</select>

Couple of things to note, do not add 'runat="server"' to the select (if you
do this and switch from HTML to design in VS, VS messes your code up). If you
wish to postback on selection change you will have to add more custom code
starting with adding 'onchange="_doPostBack('','');"' to the select. If your
unsure about the _doPostBack just google it theres plenty out there on that.

Also if you need to validate the dropdown?! (which i'm doing). I did it by
adding a asp:TextBox add a RequiredFieldValidator to the TB and in the select
put 'onchange="tbDropDownSelection.value =
this.options[this.selectedIndex].value"'. This validates the dropdown
selection when the forms submit button is clicked.

Hope any of this helps, Regards
Gav
 
Back
Top