Hello.
I have a recusive-method that creates a unordered list from a XML document. To check which node I am positioned on I use the querystring to match the URL in the XML document.
I need to add the class 'current' on the parent node if I am positioned on its child node.
Like this:
MenuItem 1 MenuItem 2 [class current] MenuItem 3 [class current] (selected node) MenuItem 4
My XML document is like this:
<MenuItem Name="MenuItem 1" Url="MenuItem1.aspx"/>
<MenuItem Name="MenuItem 2" Url="MenuItem2.aspx">
<MenuItem Name="MenuItem 3" Url="MenuItem3.aspx" />
</MenuItem>
<MenuItem Name="MenuItem4" Url="MenuItem4.asp" />
And my current code looks like this:
foreach (XmlNode item in menuitems)
{
if (HttpContext.Current.Request.Url.AbsolutePath.ToLower() == item.Attributes["Url"].Value.ToLower())
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, "current");
}
writer.RenderBeginTag(HtmlTextWriterTag.Li);
// And so on...
}
So I need some kind of function to find this node and place a class on that node aswell.
If you need more code, information or anything else - please say so! :-)
Thank you!