Link to home
Start Free TrialLog in
Avatar of BrainyYack1
BrainyYack1

asked on

Display HTML (bullets) in asp.net

     I tried to use the following codes to display a bullet list in asp.net:

      String stringBullet = "<UL><LI>point1</LI><LI>point2</LI></UL>" ;
      Label.Text = stringBullet;

      But it failed to display the bullet.

      When I debug it in Visual Studio, use the "HTML visualization", I can see the stringBullet = "<UL><LI>point1</LI><LI>point2</LI></UL>"  displayed as bullet.

      Any help is appreciated
     


   
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

Label controls automatically part <, >, &, etc into the appropriate entities: &lt;, &gt:, &amp;, etc.  You want to use a literal control for this instead.
ASKER CERTIFIED SOLUTION
Avatar of Dustin Hopkins
Dustin Hopkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BrainyYack1
BrainyYack1

ASKER

I tried literal control, but it does not work.
The following is what I used:
   <asp:Literal ID="LiteralDescription" runat="server"></asp:Literal>
   LiteralDescription.Text = "<UL><LI>point1</LI><LI>point2</LI></UL>"

I did not use any css for the label and Literal control .
Sorry I forgot to say that the text part of the bullet is displayed. The problem is that the symbol (such as round dot) part of the bullet is not displayed.
First open the rendered page in the browser and view your source there to make sure the rendered html is what you expected.  If it is, then I have to point you back to what dusion said:  check your styles.  Is it possible a style intended to act somewhere else is cascading to this element, too?

 Yes, dusion and jcoehoorn are right. It is the css that hides the bullet symbol.

Now the bullet symbol can be displayed in IE, but cannot be displayed in Firefox.

Please give further help, thanks.
when you view the page, is it atleast displaying the html correctly in both browsers?
Yes. the html  is the same in both browser. Please see the follow:
IE:
<UL><LI>
<DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3><SPAN id=ctl00_ContentPlaceHolder1_lblJobCategory>asasasasas</SPAN></FONT></DIV></LI></UL>

FireFox:
<UL><LI>
<DIV class=MsoNormal style="MARGIN: 0in 0in 0pt"><FONT face="Times New Roman" size=3><SPAN id=ctl00_ContentPlaceHolder1_lblJobCategory>asasasasas</SPAN></FONT></DIV></LI></UL>
</FONT> ?  That's not strictly valid html, since the font tag is deprecated and it's not correctly paired with an opening tag.  It could easily be what's confusing the browser's rendering.
Oops:  just spotted the opening font tag.
hmm...i would take another look at the css, as the code above shows fine in both browsers, of course i couldn't test it with the class, that looks like one of those word formatted output, you should definatly clean that up. one way to test if its the css is just put the text <UL><LI>point1</LI><LI>point2</LI></UL> into the page, outside of the literal control...if you still don't see the bullets then there is somesort of css that is screwing with your output. Also does it work if you take out the mso formatted divs?
Copied your code to a plain html file- no extra styles or anything to get in the way.  The bullet shows fine for me.  If you view this file and the bullet shows up, it's definitely a style problem.  If the bullet does not show up, you've done something to your browsers.
Ah, it looks like it lost my file.  You'll have to rename this to an html file instead of a txt file.
a.txt

jcoehoorn said it. it is because of my firefox which cached the previous css. After I cleared the cache in firefox, the bullet shows.

Thank dusion and jcoehoorn very much!
hi
can you try this way?

<ul>

<li type="circle">Circle bullet style</li>

<li type="disc">Disc bullet style</li>

<li type="square">Square bullet style</li>

</ul>