Kentico 8.1 Repeater path in transformation does not resolve using <%# Eval("DocumentName") %>

Shweta S asked on May 4, 2016 00:26

Hi,

I have a repeater control in a transformation and I am using <%# Eval("DocumentName") %> in the path. My question is, the eval does not work and gives "The server tag is not well formed." error but if I hardcode the path it works as expected. Also if I just display <%# Eval("DocumentName") %> into the div then the document name is rendered correctly as expected but the same does not work inside path attribute.

Example:

<cms:CMSRepeater runat="server" ID="users" ClassNames="MySite.Users" TransformationName="MySite.Users.Default" Path="/<%# Eval("DocumentName") %>/%"></cms:CMSRepeater>

<%# Eval("DocumentName") %>

I also tried creating transformation method to return document name to be called inside the path attribute. In that case, no error is displayed but also nothing is displayed on the screen.

Recent Answers


Brenden Kehren answered on May 4, 2016 02:12

The problem is the field DocumentName can contain spaces in it which could be why it errors out. You should use NodeName, which will have a URL friendly path in it.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on May 4, 2016 02:15

You have to configure parent repeater appropriately and specify nested control ID, so system will initialize it correctly. See documentation on this.

I'd recommend you using hierarchical viewer - is it easier to setup and better performance wise.

1 votesVote for this answer Mark as a Correct answer

Anton Grekhovodov answered on May 4, 2016 07:46

You can't use double quotes within other double quotes, so try to use single quotes for server attribute and double for Eval

<cms:CMSRepeater runat="server" ID="users" ClassNames="MySite.Users" TransformationName="MySite.Users.Default" Path='/<%# Eval("DocumentName") %>/%'></cms:CMSRepeater>

And use NodeName instead of DocumentName as Brenden said

2 votesVote for this answer Mark as a Correct answer

Shweta S answered on May 4, 2016 18:42

Thank you Brenden, Roman and Anton. It worked after I specified nested control ID in my parent repeater and also after I used single quotes instead of double quotes. Also DocumentName or NodeName returned the same value so either can be used.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 5, 2016 06:57

DocumentName and NodeName are NOT the same. Try a test page once and enter the page name of "test name". You'll quickly see NodeName replaces spaces with dashes ( - ) whereas the DocumentName will not.

0 votesVote for this answer Mark as a Correct answer

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