BulletedList inside BulletedList

S

Stan SR

Hi,

I need to add (dynamically) sub bulletedList to a bulletedList

Ex :
<ul>
<li>store A
<ul>
<li>Europe</li>
<li>Africa</li>
</ul>
</li>
<li>store B
<ul>
<li>Asia</li>
<li>Africa</li>
</ul>
</li>
</ul>



Here's what I wrote

the main UL is called BulletedList1

BulletedList node = new BulletedList();
node.Items.add("Europe");
BulletedList1.Items.add(node) -> it doesn't work


Any idea ?
Stan
 
K

Ken Cox [Microsoft MVP]

Hi Stan,

Wouldn't it be easier to use the TreeView control with its style set to
Bullet List?

It would be far easier to add a node on the fly. The code below shows a
little VB sample of how it might work as a TreeView.

Let us know how you make out?


Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Button1_Click _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim chnode As TreeNode
chnode = New TreeNode
chnode.Text = "Europe"
chnode.SelectAction = TreeNodeSelectAction.None
TreeView1.Nodes(0).ChildNodes.Add(chnode)
chnode = New TreeNode
chnode.Text = "Africa"
chnode.SelectAction = TreeNodeSelectAction.None
TreeView1.Nodes(0).ChildNodes.Add(chnode)
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView as Bulleted List</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:treeview id="TreeView1" enableclientscript="false"
runat="server" imageset="BulletedList" showexpandcollapse="False">
<parentnodestyle font-bold="False" />
<hovernodestyle font-underline="True" forecolor="#5555DD" />
<selectednodestyle font-underline="True" forecolor="#5555DD"
horizontalpadding="0px" verticalpadding="0px" />
<nodestyle font-names="Verdana" font-size="8pt"
forecolor="Black" horizontalpadding="0px" nodespacing="0px"
verticalpadding="0px" />
<nodes>
<asp:treenode selectaction="None" text="Store A"
value="Store A"></asp:treenode>
<asp:treenode selectaction="None" text="Store B"
value="Store B"></asp:treenode>
</nodes>
</asp:treeview>
<br />
&nbsp;<asp:button id="Button1" runat="server"
onclick="Button1_Click" text="Add Bullets" /></div>

</form>
</body>
</html>
 
S

Stan SR

Hi Ken,
I thank you for your reply.
I don't want to use the TreeView control because it uses a Table Schema
(talking about Table, Tr, Td tags) when you look at the source.
Stan

Ken Cox said:
Hi Stan,

Wouldn't it be easier to use the TreeView control with its style set to
Bullet List?

It would be far easier to add a node on the fly. The code below shows a
little VB sample of how it might work as a TreeView.

Let us know how you make out?


Ken
Microsoft MVP [ASP.NET]

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Button1_Click _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
Dim chnode As TreeNode
chnode = New TreeNode
chnode.Text = "Europe"
chnode.SelectAction = TreeNodeSelectAction.None
TreeView1.Nodes(0).ChildNodes.Add(chnode)
chnode = New TreeNode
chnode.Text = "Africa"
chnode.SelectAction = TreeNodeSelectAction.None
TreeView1.Nodes(0).ChildNodes.Add(chnode)
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TreeView as Bulleted List</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:treeview id="TreeView1" enableclientscript="false"
runat="server" imageset="BulletedList" showexpandcollapse="False">
<parentnodestyle font-bold="False" />
<hovernodestyle font-underline="True" forecolor="#5555DD" />
<selectednodestyle font-underline="True" forecolor="#5555DD"
horizontalpadding="0px" verticalpadding="0px" />
<nodestyle font-names="Verdana" font-size="8pt"
forecolor="Black" horizontalpadding="0px" nodespacing="0px"
verticalpadding="0px" />
<nodes>
<asp:treenode selectaction="None" text="Store A"
value="Store A"></asp:treenode>
<asp:treenode selectaction="None" text="Store B"
value="Store B"></asp:treenode>
</nodes>
</asp:treeview>
<br />
&nbsp;<asp:button id="Button1" runat="server"
onclick="Button1_Click" text="Add Bullets" /></div>

</form>
</body>
</html>



Stan SR said:
Hi,

I need to add (dynamically) sub bulletedList to a bulletedList

Ex :
<ul>
<li>store A
<ul>
<li>Europe</li>
<li>Africa</li>
</ul>
</li>
<li>store B
<ul>
<li>Asia</li>
<li>Africa</li>
</ul>
</li>
</ul>



Here's what I wrote

the main UL is called BulletedList1

BulletedList node = new BulletedList();
node.Items.add("Europe");
BulletedList1.Items.add(node) -> it doesn't work


Any idea ?
Stan
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top