tags:

views:

317

answers:

5

Hi,

I have a asp:dropdownlist, which shows below code when page renders

<select id="ContactUs_ddlWhichProgrammes" name="ContactUs$ddlWhichProgrammes">
    <option value="Select an option">Select an option</option>
    <option value="InterestOptionBusiness">Business</option>
    <option value="InterestOptionEnglish">English</option>
    <option value="InterestOptionExamPreparation">Exam Preparation</option>
    <option value="InterestOptionUniversity">University</option>
    <option value="InterestOptionWorkandStudy">Work and Study</option>
</select>

Now I want to make some option text bold randomly, I mean I want English and University as bold while other text will be normal.

Please suggest is it is possible or I need to implement any other logic. The dropdown are populated from the XML.

+1  A: 

This can't be done because IE will not add bold styling to option elements.

The best you can do is change fonts, or color.

I should clarify... bolding the text will work in Firefox, but not in IE, Chrome, Opera or Safari.

e.g. basic bolding like this won't work (except in Firefox):

<select>
  <option>aaa</option>
  <option>bbb</option>
  <option>ccc</option>
  <option style="font-weight:bold;">BOLD</option>
  <option>ddd</option>
  <option>eee</option>
</select>
scunliffe
thanks, can I have some example code
MKS
A: 

You can style this by using css.

http://www.outfront.net/tutorials_02/adv_tech/funkyforms5.htm

Just asigne the options a class that has font-weight = bold.

dean nolan
unfortunately bolding options doesn't work outside of Mozilla Firefox/Gecko Browsers.
scunliffe
A: 

No browser will support styling optional <option> elements..but you can do for all the <option> element..

msarathy
can you please give me one examples
MKS
A: 

there are some tools such as Telerik RadComboBox that will allow you to do such things.

Russ Bradberry
A: 

I haven't manage to make the font bold but you can play with CSS attributes like this:

// Somewhere in your server side code...
ContactUs_ddlWhichProgrammes.Items[0].Attributes.Add("style", "font-weight: bold");
ContactUs_ddlWhichProgrammes.Items[1].Attributes.Add("style", "color: #F00");
ContactUs_ddlWhichProgrammes.Items[2].Attributes.Add("style", "background-color: #000; color: #FFF");
Maxime