For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > March 2007 > Using a custom character as the bullet in a BulletedList









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Using a custom character as the bullet in a BulletedList
Nathan Sokalski

2007-03-15, 7:15 pm

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.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/


Alexey Smirnov

2007-03-15, 7:15 pm

On Mar 15, 9:51 pm, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> 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...ist.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">

Parvathy Padmanabhan

2007-03-30, 7:07 pm



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
Nathan Sokalski

2007-03-30, 7:07 pm

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.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Parvathy Padmanabhan" <ParvathyPadmanabhan@discussions.microsoft.com> wrote
in message news:8E297BCC-06E7-4CAE-BEED-0B9C23F4D0A6@microsoft.com...
>
>
> 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



Parvathy Padmanabhan

2007-03-30, 7:07 pm

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
Nathan Sokalski

2007-03-31, 4:14 am

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.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Parvathy Padmanabhan" <ParvathyPadmanabhan@discussions.microsoft.com> wrote
in message news:A0CA33D8-233A-4A5F-B166-825737674CA8@microsoft.com...
> 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



Parvathy Padmanabhan

2007-03-31, 7:05 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com