Resources » .NET programming » ASP.NET/Web Applications

Adding attributes such as backgorund color, forecolor to the particular item of a dropdownlist

Updated: Category: ASP.NET/Web Applications
Author: Member Level: GoldPoints: 10

to set a background color or forecolor for a particular item of a dropdownlist based on some conditions

<H2>Setting Background color and Fore color of a particular item</H2>

To be frank if u try to set a background color or a fore color of a particular item in a web control dropdownlist based on some conditions using "Dropdownlist1.Item[0].Attributes.CssStyle.Add", the change will not reflect in the page while executing. To handle this, Use a html dropdownlist <Select id=Select1></Select>, make this as a server control by right click the control.

//html dropdownlist
//to execute onchange event on selected index chage [auto postback]

//web control dropdownlist
//This will not reflect..No color will be set for a particular item.

Try this...Sometimes u may come across this situation of handling different colors for different items of a dropdownlist.

Did you like this resource? Share it with your friends and show your love!

Responses to "Adding attributes such as backgorund color, forecolor to the particular item of a dropdownlist"

No responses found. Be the first to respond...


Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India


    Click the "Follow" button above to follow Tony John