Copied to clipboard

Flag this post as spam?

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


  • Niek 8 posts 28 karma points
    Nov 28, 2012 @ 21:49
    Niek
    0

    Several Razor problems in 4.11.1

    Hey all,

    I'm developing a website in Umbraco 4.11.1 and I have come across several errors:

    Problem 1: When using:

    @foreach (var page in Model.Content.AncestorsOrSelf(1))

    I get the following error:

    Compiler Error Message: CS1928: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'AncestorsOrSelf' and the best extension method overload 'Umbraco.Web.PublishedContentExtensions.AncestorsOrSelf(Umbraco.Core.Models.IPublishedContent, string)' has some invalid arguments

    Problem 2: When using:

    @item.GetPropertyValue<DateTime>("datum").ToString("dd MMMM yyyy")

    I get the following error:

    Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

    To fix it I need to format the Razor code as:

    @(item.GetPropertyValue<DateTime>("datum").ToString("dd MMMM yyyy"))

    Problem 3: When using:

    var image = new DAMP.PropertyEditorValueConverter.Model(item.GetPropertyValue("afbeelding"))

    I get the following error:

    Compiler Error Message: CS1502: The best overloaded method match for 'DAMP.PropertyEditorValueConverter.Model.Model(string)' has some invalid arguments

    To fix it I need to format the Razor code as:

    var image = new DAMP.PropertyEditorValueConverter.Model(item.GetPropertyValue<int>("afbeelding").ToString())

    Also, when the "afbeelding" property has no value, Count() still returns 1. But the DAMP_Item object in the list is empty.

    Problem 4:

    It seems like the Random(int) method on IPublishedContent is missing?

    Is something wrong with my Umbraco installation or is it me doing something wrong?

    Kind regards,

    Niek

  • Nathalie Larsson 2 posts 22 karma points c-trib
    Nov 29, 2012 @ 22:53
    Nathalie Larsson
    0

    I have the same errors. Have you managed to solve it Niek? 

  • Niek 8 posts 28 karma points
    Dec 03, 2012 @ 09:26
    Niek
    0

    I haven't managed to solve it yet...

    Maybe someone else could help us?

  • Halldór Hrafn 15 posts 72 karma points
    Dec 03, 2012 @ 11:55
    Halldór Hrafn
    0

    I had a similar problem (I think) where I couldn't sort on my properties within Razor scripts.

    for example: .OrderBy("myUmbracoProperty desc")

    This worked in 4.9, but not after I upgrated to 4.11 :P

    After quite alot of hairpulling I tried to re-save my document type (which has the property), which resulted in a server error (ysod). I then tried to save it again (this time from the server, might have worked remotely).

    Now I can sort by my property.

    However I have to make sure I ONLY select nodes that DO have the (sorting) property, this wasn't a problem before (and is still causing me issues) :P

    NB:

    • I also noticed that I could sort by properties on some other document types.
    • My have set up a little complicated document type structure, the problem DT was on level 3, that is it was a descendant of 2 other DTs

    Hope this helps...

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies