Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul Tibble 1 post 71 karma points
    Feb 18, 2019 @ 11:25
    Paul Tibble
    0

    "Umbraco.Web.Models.RelatedLink' does not contain a definition for 'Value'"

    Hi there,

    I am having an issue with a page on my site. I have taken over the site from an external development company who have left me to it. So any help is greatly appreciated.

    The error i am getting is 'Umbraco.Web.Models.RelatedLink' does not contain a definition for 'Value''

    And the lines in question are as follows;

     @{
                if(CurrentPage.GetPropertyValue("videoLink").ToString() == "True"){
                    foreach (var button in CurrentPage.GetPropertyValue("link"))
                {
                        var linkUrl = (button.Value<bool>("isInternal")) ? Umbraco.NiceUrl(button.Value<int>("internal")) : button.Value<string>("link");
                        var linkTarget = button.Value<bool>("newWindow") ? "_blank" : null;
                        <a href="@linkUrl" target="@linkTarget" class="button blue-button" data-lity>@(button.Value<string>("caption"))</a>
                }
                    }else{
                    foreach (var button in CurrentPage.GetPropertyValue("link"))
                    {
                        var linkUrl = (button.Value<bool>("isInternal")) ? Umbraco.NiceUrl(button.Value<int>("internal")) : button.Value<string>("link");
                        var linkTarget = button.Value<bool>("newWindow") ? "_blank" : null;
                        <a href="@linkUrl" target="@linkTarget" class="button blue-button">@(button.Value<string>("caption"))</a>
                    }
                }
            } 
    

    Thank you in advance and if I have broken any forum rules in this I apologise.

  • Chris Evans 137 posts 353 karma points c-trib
    Feb 18, 2019 @ 23:15
    Chris Evans
    0

    Without knowing a bit more about your setup it's hard to suggest a definite fix.

    The version of Umbraco you're using is important as some changes have been made to the Related Links datatype during the life of Umbraco 7. It would also be useful to see the rest of the View here, particularly the using statements at the top.

    But have a look at this forum post:

    https://our.umbraco.com/forum/templates-partial-views-and-macros/85224-umbraco-76-rc-related-links-umbracowebmodelsrelatedlink-does-not-contain-a-definition-for-link-or-for-isinternal

    It shows some useful links and examples on how to query the Related Links datatype.

    The short answer is that your code is using dynamics, when you might have more luck using strongly typed objects. The forum post above covers that as well.

    Hope this helps,

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft