0

How can I display selected part of an asp.net string with HTML Formatting.

Eg:

String str= "Yerevan Airport(<B>UB21</B>,AM-ER,Yerevan,)";

I need to display the text enclosed in <B> and </B> in bold and display it as text in RADComboBox.

I have tried it with using StringBuilder , HttpUtility.Htmlencode, String.Format but couldn't find any proper solution.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Amruta
  • 701
  • 4
  • 15
  • 38
  • possible replica of http://stackoverflow.com/questions/607529/asp-net-how-to-render-html-tags-in-a-listitem-text-property – Usman Jun 12 '12 at 07:18

3 Answers3

0

What you are trying to achieve is not possible.

The DropDownList control of ASP.Net renders to a html <select> control which doesn't allow markup inside it's <option> elements.

Filburt
  • 17,626
  • 12
  • 64
  • 115
0

Try this:

  String str = "Yerevan Airport &lt;BR /&gt; UB21 &lt;BR /&gt;";
  String strHtml = Server.HtmlDecode(str);
Jagz W
  • 855
  • 3
  • 12
  • 28
  • 1
    Apart from the fact that `
    ` wasn't asked for, this is just manually html-encoding and then decoding which will result in exactly the same string literal the OP started with.
    – Filburt Jun 12 '12 at 07:30
  • Hi , I tried using the above code , but it still isnt working.Actually I want to work out this scenario on a telerik .radcombobox – Amruta Jun 12 '12 at 07:34
0

For using RadComboBox , follow this url

http://www.telerik.com/community/forums/aspnet-ajax/combobox/how-to-make-a-part-of-the-radcomboboxitem-text-bold.aspx

Usman
  • 3,200
  • 3
  • 28
  • 47