A custom page type is storing a multi choice form control property value as a pipe delimited string such as "foo|bar".
Within a page type ASCX transformation I'm able to successfully retrieve and display the foo|bar property value using:
<div><%# Eval("Foobar") %></div>
The goal is to split this string value on the pipe | character and output each value, but I'm unable to achieve this using the page type transformation ASCX syntax.
Trying the following gives me error "error CS0230: Type and identifier are both required in a foreach statement":
<ul>
<% foreach (thing in Eval<string>("Foobar").Split('|')) { %>
<li><%= thing %></li>
<% } %>
</ul>
<ul class="list-unstyled">
<%
things = Eval<string>("Foobar").Split('|');
foreach (thing in things) {
%>
<li><%= topic %></li>
<% } %>
</ul>
Trying set type to string or var causes a system wide exception and prevents the site from loading:
<ul>
<% foreach (string thing in Eval<string>("Foobar").Split('|')) { %>
<li><%= thing %></li>
<% } %>
</ul>
<ul>
<% foreach (var thing in Eval<string>("Foobar").Split('|')) { %>
<li><%= thing %></li>
<% } %>
</ul>
<ul class="list-unstyled">
<%
var things = Eval<string>("Foobar").Split('|');
foreach (var thing in things) {
%>
<li><%= thing %></li>
<% } %>
</ul>
Trying a for loop and targeting the string[] topics results in an error of "CS0103: The name 'topics' does not exist in the current context":
<ul class="list-unstyled">
<%
things = Eval<string>("Foobar").Split('|');
for(int i = 0; i < things.Length; i++) {
%>
<li><%= things[i] %></li>
<% } %>
</ul>
How can I achieve retrieving the value for the page type/document, splitting on the pipe character, then display each resulting string[] array value? Should I be using a different type of transformation?
Thank you for any help you can provide!