Search code examples
razortextboxumbracoumbraco7

Umbraco 7 Multiple Textbox pulling "System.String[]"


I am currently using Umbraco 7.1.8 and I have just finished my final template however I wanted to create a tag like list for the client to add in as they wish.

I have a multiple textbox with the alias workUndertaken however when I call it, it echos System.String[].

My code is pretty simple - I called it two different ways to ensure it wasn't an issue with one method.

<p>@Model.Content.GetPropertyValue("workUndertaken")</p>
<p>@Umbraco.Field("workUndertaken")</p>

Does anyone know where I am going wrong?


Solution

  • Sorry got the answer almost instantly. Was hard to find.

    So I will post the answer with the code I am now using. Hopefully others find this useful.

    @{
      if (Model.Content.GetPropertyValue<string[]>("workUndertaken").Length > 0) {
       <ul>
           @foreach (var item in Model.Content.GetPropertyValue<string[]>("workUndertaken")) {
              <li>@item</li>
           }
       </ul>
     }
    

    }