How do you add screen reader attributes to anchor tag

Robert Srigley asked on January 23, 2018 17:28

In the Item Template of a Hierarchical Transformation I have the following code;

<li class="nav-item <%# IfTrue(IsDocumentOnSelectedPath(),"active") %>"><a class="nav-link <%# IfTrue(IsDocumentOnSelectedPath(),"active") %>" href="<%# GetDocumentUrl() %>"><%# Eval("MenuItemName") %></a>
<cms:SubLevelPlaceHolder runat="server" Id="plcSub" />
</li>

How do I add the following code the the active menu on the <a> tag?
<span class="sr-only">(current)</span>

Correct Answer

Brenden Kehren answered on January 24, 2018 20:06

Very similar to how you've already done the other If statements:

<li class="nav-item <%# IfTrue(IsDocumentOnSelectedPath(),"active") %>">
    <a class="nav-link <%# IfTrue(IsDocumentOnSelectedPath(),"active") %>" href="<%# GetDocumentUrl() %>"><%# Eval("MenuItemName") %>
    <%# IfTrue(IsDocumentOnSelectedPath(), "<span class=\"sr-only\">(current)</span>") %>
    </a>
    <cms:SubLevelPlaceHolder runat="server" Id="plcSub" />
</li>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Robert Srigley answered on January 24, 2018 20:51

Thank you Brenden, I see I only needed to escape the quotation marks.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.