GetDocumentURL in if Statement (Transformation)

Romina Herrera asked on March 25, 2016 18:52

I am having trouble getting the GetDocumentURL() to actually fecth the URL for the transformed item in my conditional statement.

This is my code:

<div class="summary">
    <p><%# IfEmpty(Eval("summary"),"",Eval("summary")) %>
    <%# IfEmpty(Eval("summary"), "", "<a href='GetDocumentUrl()'>Read more.</a>") %><br /></p>
</div>

Correct Answer

Laura Frese answered on March 25, 2016 22:18

You might try another work around, if your page name is the url alias you could replace the space with whatever character is filling spaces. Note that this wont work in all cases - like if the url is cut short or different than the page name.

<%# IfEmpty(Eval("summary"), "", "<a href='/path/to/page/" + Eval("MyPageName").ToString().Replace(" ","-") + "'>Read more.</a>") %>
1 votesVote for this answer Unmark Correct answer

Recent Answers


Bryan Soltis answered on March 25, 2016 19:13 (last edited on March 25, 2016 20:11)

Hi Romina,

It looks like you just need to build up your link properly.

<div class="summary">
    <p><%# IfEmpty(Eval("summary"),"",Eval("summary")) %>
    <%# IfEmpty(Eval("summary"), "", "<a href='" + GetDocumentUrl() + "'>Read more.</a>") %><br /></p>
</div>
  • Bryan
0 votesVote for this answer Mark as a Correct answer

Romina Herrera answered on March 25, 2016 19:44

Hi Bryan, when I build it like that, the link sends me to /default.aspx

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 25, 2016 19:52

Romina, what is the path and settings of your repeater that is using this?

I would add <%# Eval("NodeAliasPath") %> just to see what objects are being rendered, i have a feeling it's /default.aspx because it's only rendering the root/default object.

0 votesVote for this answer Mark as a Correct answer

Romina Herrera answered on March 25, 2016 20:12

Trevor, I can't use <%# Eval("NodeAliasPath") %> because it breaks my conditional statement, using it like this, I get linked to the parent page of the current page:

 <div class="contentText contentTextTeaser">
<div class="text">
<p><%# IfEmpty(Eval("summary"),"",Eval("summary")) %> 
<%# IfEmpty(Eval("summary"), "", "<a href='" + Eval("NodeAliasPath") + "'>Read more.</a>") %><br /></p>

0 votesVote for this answer Mark as a Correct answer

Romina Herrera answered on March 28, 2016 18:43

Hi Laura, your solution worked! All the pages are stored in the same sub-directory, and all the page names match the title of the page, so this fix has solved my problem, thank you.

0 votesVote for this answer Mark as a Correct answer

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