Well, I just avoided the Treeview control completely. I figured I would post
my solution, in case someone else has a similar issue. Bascially I have a
literal and a SiteMapDataSource. I loop through the SiteMapDataSource Nodes
and build the <div> tags dynamically. I could have used a repeater instead
of a literal but I needed to have the node only expanded if it was the parent
of the selected node and collapsed if it is not.
protected void Page_Load(object sender, EventArgs e)
{
litRightNav.Text =
string.Format("{0}",DisplaySiteMapLevelAsBulletedL ist());
}
private string DisplaySiteMapLevelAsBulletedList()
{
SiteMapDataSourceView siteMapView =
((SiteMapDataSourceView)(SiteMapData.GetView(strin g.Empty)));
SiteMapNodeCollection nodes =
((SiteMapNodeCollection)(siteMapView.Select(DataSo urceSelectArguments.Empty)));
return GetSiteMapLevelAsBulletedList(nodes,false);
}
private string GetSiteMapLevelAsBulletedList(SiteMapNodeCollectio n
nodes, bool indent)
{
string output = string.Empty;
string cssClass = "rightNavHighlight";
string cssClassSelected = "rightNavHighlightAct";
string div = "<div class=\"rightNavHighlight\">";
bool getChildren;
string currentPath = CmsHttpContext.Current.Posting.Path;
string currentPosting = CmsHttpContext.Current.Posting.DisplayName;
if (indent)
{
div = div.Replace("\">", " marginLeft10px\">");
}
foreach (SiteMapNode node in nodes)
{
if (currentPosting == node.Title)
{
div = div.Replace("rightNavHighlight",
"rightNavHighlightAct");
}
else
{
div = div.Replace("Act", "");
}
getChildren = (currentPath.IndexOf(node.Url) > -1 && indent ==
false);
output += string.Format(div + "<a href=\"{0}\">{1}</a></div>",
node.Url, node.Title);
if (node.HasChildNodes && getChildren && (indent==false))
{
output += string.Format("{0}",
GetSiteMapLevelAsBulletedList(node.ChildNodes,true ));
}
}
return output;
}
--
James Coleman
Technical Director
AGENCY.COM [Chicago]
"James Coleman" wrote:
I am using the TreeView control in ASP.NET 2.0 and like it. However, our
sitebuilders aren't too pleased with the idea of the table that gets
rendered. They are big into avoiding <table> tags when it comes to site
build.
So is there a way I could have the following html be rendered from the
treeview control?
<div class="rightNavHighlight"><a href="#">Ergonomics</a></div>
<div class="rightNavHighlight"><a href="#">Environmental
Responsibility</a></div>
<div class="rightNavHighlight"><a href="#">Workplace Trends</a></div>
<div class="rightNavHighlight"><a href="#">Typicals Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Image Gallery</a></div>
<div class="rightNavHighlight"><a href="#">Project Profiles</a></div>
<div class="rightNavHighlightAct"><a href="#">Case Studies</a></div>
<div class="rightNavHighlight"><a href="#">Real Life Stories</a></div>
<div class="rightNavHighlight"><a href="#">White Papers</a></div>
<div class="rightNavHighlight"><a href="#">Product Solution Center</a></div>
<div class="rightNavHighlight"><a href="#">Product Document Library</a></div>
Thanks for the help.
--
James Coleman
Technical Director
AGENCY.COM [Chicago]