Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Highlighting DropDownList Items jQuery & .NET

  • 12-05-2011 10:13AM
    #1
    Registered Users, Registered Users 2 Posts: 527 ✭✭✭


    Hi all,

    I have a dropdown list in my C# / .NET project that is on a child page (within a Master page).

    I am applying the jQuery selectmenu styling via the master page:
    $(function () {
       $('select[id*="lstClients"]').selectmenu({ style: 'dropdown', maxHeight: 150 });
    });
    

    I need to give certain items in the dropdown a different background colour.

    e.g. if ClientX has Y number of projects then set the background colour to red or something like that.

    I have all of the data/counters being populated via the code-behind so basically what I am asking is if anyone knows how I can change the background colour of certain items in the dropdown via C# ?

    Thanks in advance


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 9,205 Mod ✭✭✭✭mewso


    Well I don't know much about the selectmenu but I had a look. On the .net side you would be looking to output class values for each item depending on the client's project count (dropdownlist databound event). Then in css specify the bg colours for those class values. The selectmenu will pick up those class values and apply it to the menuitems it creates so you should be able to override the colours. It may require very specific css -

    ul.ui-selectmenu-menu li.lowpojectcount {
    /*style*/
    }


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Select boxes can be funny......I know that in some cases they're an OS control and dislike styling (e.g. borders are VERY hairy) and in others there are speed issues - IE is VERY slow to complete a jQuery .remove()


Advertisement