Adding an anchor tag in a repeater transformation

L Younkins asked on January 31, 2022 23:10

I have an Accordion Tab repeater that I would like to add an anchor tag to each unique title within the transformation.

Here is my code:

<li>
<a href="#tab-<%# DataItemIndex+1%>-<%# Container.Parent.Parent.ClientID %>" title="<%# Eval("Title") %>">
  <span class="tab-item-title"><%# Eval("Title") %></span>
  <span class="ui-icon"></span>
  <%# String.IsNullOrEmpty(Eval<string>("MainText")) ? "" : "<div class=\"tab-item-subtitle\">" + Eval("MainText") + "</div>" %>
</a>
</li>

I tried adding:

<a id="<%# Eval("AnchorLinkName") %>" name="<%# Eval("AnchorLinkName") %>"></a>, 

but it didnt work. text

Correct Answer

Brenden Kehren answered on February 2, 2022 17:41

Typically what you do in this case is have a datasource web part on the page and specify the necessary fields (where, page types, order by, etc.). You take note of the datasources name and add that to two repeaters on the page. One repeater is or your anchor link navigation and the other is the actual content you wish to display (link to).

One thing to note, is the anchor link needs to be a URL friendly value. So something with spaces or un-encoded URL values will NOT work.

In your navigation repeater (where you link FROM), you'll need something like the following in the transformation:

<li>
    <a href="#faq-<%# Eval("DocumentID") %>"><%# Eval("DocumentName") %></a>
</li>

In your listing repeater (where you link TO), you'll need something like the following in the transformation:

<div class="faq-item" id="faq-<%# Eval("DocumentID") %>">
... your content here
</div>

Reference W3Schools Bookmarks

0 votesVote for this answer Unmark Correct answer

Recent Answers


L Younkins answered on February 2, 2022 17:45

Thank you.

0 votesVote for this answer Mark as a Correct answer

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