Copied to clipboard

Flag this post as spam?

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


  • Sören Deger 733 posts 2844 karma points c-trib
    Sep 21, 2012 @ 16:31
    Sören Deger
    0

    Razor error in umbraco 4.9 with empty string

    Hi,

    i have a simple razor-script. It works in umbraco 4.7.0 and 4.7.1 perfectly:

                                if (@item.HasProperty("bodyText"))
                                {
                                    if(@item.bodyText!="")
                                    {        
                                        <p class="flex-caption">@item.bodyText</p>
                                    }
                                }

    But in Umbraco 4.9 i get only this simple error message:

    Error loading MacroEngine script

    If I write String.Empty instead of "" it doesn't work too.

    The problem is the second if-statement. Without this second if-statement it works....

    Have anyone an idea to solve this error?

     

    Regards Sören

     

  • Sören Deger 733 posts 2844 karma points c-trib
    Sep 21, 2012 @ 16:39
    Sören Deger
    0

    Now, it works with following code:

                                if (@item.HasProperty("bodyText"))
                                {
                                    if(@item.bodyText.ToString()!=String.Empty)
                                    {        
                                        <p class="flex-caption">@item.bodyText</p>
                                    }
                                }

    I must add .ToString()

    I'm confused, because the property with alias bodyText has the datatype tinyMCE and in 4.7.1 it works without .ToString().

    Are their any changes in Razor in Umbraco 4.9???

     

    Regards Sören

     

Please Sign in or register to post replies

Write your reply to:

Draft