Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Highlighting DropDownList Items jQuery & .NET

Options
  • 12-05-2011 10:13am
    #1
    Registered Users 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: 8,920 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