Using a custom character as the bullet in a BulletedList

N

Nathan Sokalski

I am creating a BulletedList and would like to use a - as the bullet.
However, I could not find a way to do this using the properties for the
BulletedList control. Is there a way to use a specific character for the
bullet without manually adding it to each ListItem? Thanks.
 
G

Guest

I am creating a BulletedList and would like to use a - as the bullet.
However, I could not find a way to do this using the properties for the
BulletedList control. Is there a way to use a specific character for the
bullet without manually adding it to each ListItem? Thanks.

To control the style of bullet used, use the BulletedList.BulletSyle
property:

http://msdn2.microsoft.com/en-us/li...controls.bulletedlist.bulletstyle(VS.80).aspx

It has no standard style for a "-", but you can use a custom image,
for example:

<asp:BulletedList BulletImageUrl="/images/minus.gif"
BulletStyle="CustomImage">
 
G

Guest

If u desire some special charecter as a bullet for the bullet list, you
could try this option.

<asp:BulletedList ID="BulletedList1"
style="list-style-type: none;"
DataTextField="bulletContent"
runat="server"
DataTextFormatString="- {0:0}" >
</asp:BulletedList>

The style property's list-style-type needs to be set to none, so that the
browser does not prefix the content with the default bullet. The special
charecter that you would like to use as your bullet can be given in the
DataTextFormatString property of the bullet list " - {0:0}".
I hope this helps.

-Parvathy Padmanabhan
 
N

Nathan Sokalski

Would that work if I am not using DataBinding? It looks to me like you
assumed I was using DataBinding, but there are many cases with BulletedLists
that I do not use DataBinding. Would your suggestion still work? Thanks.
 
G

Guest

Hi,

If you donot have a datasource object and need to give asp:ListItem
objects in the html source, in that case, retain the
style="list-style-type: none;" property of the bulletlist and remove the
DataTextFormatString="- {0:0}" property.

To each of your asp:ListItem 's text property prifix the value with "- ".

<asp:BulletedList ID="BulletedList1" style="list-style-type: none;"
runat="server">
<asp:ListItem Text="- Item 1" Value="1"></asp:ListItem>
<asp:ListItem Text="- Item 2" Value="2"></asp:ListItem>
</asp:BulletedList>

-Parvathy Padmanabhan
 
N

Nathan Sokalski

I realize that that would give the same initial result, but it takes away
the option to use or set the text property without extra coding. In other
words, I want the Text property to be the text and nothing but the text so
that I can easily work with the text property in the codebehind. Any other
ideas? Thanks.
 
G

Guest

Hi,
In that case, probabaly creating a - image and giving the bullet image url
should help.
But the ListItem also has a Value attribute. Can you not set the value
attribute and use that for the processing in the code behind, or is it that
you are using both the text and the value for totally diffrent things..? To
what i know the only options what cld be tried are,

1. Create a Datatable object, bind it to your control. That way you can use
the DataTextFormat property.
2. Prefix the text content with a "-" and set the text that u need for the
processing in the code behind to the value property of the listItem.
3. Create a "-" as an image and pass the bulletImage url.

So, its up to you to chose what cld best suit your requirement.

Jus incase you do come up with another way of doing it..kindly update me on
it.

-Parvathy Padmanabhan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top