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 SiteMapDataSour ce. I loop through the SiteMapDataSour ce 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(objec t sender, EventArgs e)
{
litRightNav.Tex t =
string.Format(" {0}",DisplaySit eMapLevelAsBull etedList());
}
private string DisplaySiteMapL evelAsBulletedL ist()
{
SiteMapDataSour ceView siteMapView =
((SiteMapDataSo urceView)(SiteM apData.GetView( string.Empty))) ;
SiteMapNodeColl ection nodes =
((SiteMapNodeCo llection)(siteM apView.Select(D ataSourceSelect Arguments.Empty )));
return GetSiteMapLevel AsBulletedList( nodes,false);
}
private string GetSiteMapLevel AsBulletedList( SiteMapNodeColl ection
nodes, bool indent)
{
string output = string.Empty;
string cssClass = "rightNavHighli ght";
string cssClassSelecte d = "rightNavHighli ghtAct";
string div = "<div class=\"rightNa vHighlight\">";
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("ri ghtNavHighlight ",
"rightNavHighli ghtAct");
}
else
{
div = div.Replace("Ac t", "");
}
getChildren = (currentPath.In dexOf(node.Url) > -1 && indent ==
false);
output += string.Format(d iv + "<a href=\"{0}\">{1 }</a></div>",
node.Url, node.Title);
if (node.HasChildN odes && getChildren && (indent==false) )
{
output += string.Format(" {0}",
GetSiteMapLevel AsBulletedList( 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="rightNav Highlight"><a href="#">Ergono mics</a></div>
<div class="rightNav Highlight"><a href="#">Enviro nmental
Responsibility</a></div>
<div class="rightNav Highlight"><a href="#">Workpl ace Trends</a></div>
<div class="rightNav Highlight"><a href="#">Typica ls Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Image Gallery</a></div>
<div class="rightNav Highlight"><a href="#">Projec t Profiles</a></div>
<div class="rightNav HighlightAct">< a href="#">Case Studies</a></div>
<div class="rightNav Highlight"><a href="#">Real Life Stories</a></div>
<div class="rightNav Highlight"><a href="#">White Papers</a></div>
<div class="rightNav Highlight"><a href="#">Produc t Solution Center</a></div>
<div class="rightNav Highlight"><a href="#">Produc t Document Library</a></div>
Thanks for the help.
--
James Coleman
Technical Director
AGENCY.COM [Chicago]