I want to add a html tag to a string for styling purpose
ListItem item = new ListItem("abc", "www.http://stackoverflow.com");
blogList.Items.Add(item);
I want to add tag to string “abc”. I looked into HtmlString and HtmlStringWriter but
they look too complicated.
Can anyone demonstrate a small piece of working code? or any method I can use?
To add a specific css attribute you can use:
to add a css style already defined in your style sheet you can use:
I’m not sure why you want HTML within a list item’s text, as it seems problematic as Gilbert pointed out, but if you just want to dynamically add HTML to your page there are many ways, including using a Label or a Literal. Simply declare an
<asp:Literal ID="myLit"..>object on your .aspx page, then within your code source (.cs) file saymyLit.Text = "<p>Some HTML</p>";