As part of an abstracted method for changing styles on <a> HtmlAnchors I tried to recurse down through child controls starting with a parameter control. However, the <a> HtmlAnchors within the <td> HtmlTableCells are never seen by the method. aspx and asp.cs extract as follows:
------------------
Code:
<tr id="trSupplierLinks" runat="server">
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/details_new.aspx'>Details
& Service Zones</a></td>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/instructions.aspx'>Instructions
&<br>
Information</a></td>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/rates_manage.aspx'>General
Waste Schedule</a></td>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/rates_manage_clean.aspx'>Clean
Fill Schedule</a></td>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/rates_manage_green.aspx'>Green
Waste Schedule</a></td>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='<%=Application["VirPath"]%>supplier/rates_manage.aspx?logout=true'>Log
Out</a></td>
<td>
<asp:Literal ID="litTest" Visible="False" Runat=server>
<td valign="top">|</td>
<td valign="top"><a class="navagation_link_normal" href='order_receipting.aspx'>Order
Receipting</a></td></asp:Literal></td>
</tr>
Code:
protected void UpdateNavagationLinks(Control objLinksParent)
{
HtmlAnchor objNavLink;
string sCurrentURL = Request.ServerVariables["URL"];
string sStyleClass;
foreach (Control objNavControl in objLinksParent.Controls)
{
if(objNavControl.GetType() == Type.GetType("HtmlAnchor"))
{
objNavLink = (HtmlAnchor)objNavControl;
sStyleClass = objNavLink.Attributes["class"];
if(sStyleClass.IndexOf("navagation_link") < 1)
{
continue;
}
aText.Text = aText.Text + objNavLink.HRef + " " + sCurrentURL;
if(objNavLink.HRef == sCurrentURL)
{
sStyleClass = "navagation_link_current";
}
else
{
sStyleClass = "navagation_link_normal";
}
}
UpdateNavagationLinks(objNavControl);
}
}
Strangly enough the "|"'s *do* show up in the method (as HtmlLiterals). But the anchor tags dont.
Thanks in advance.