Copied to clipboard

Flag this post as spam?

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


  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 08:14
    Jhon
    1

    Getting some error

    Hi,

    I have written this code, now i am getting some error , i can not understand , can you please help me. Can you please look at my code.

    enter image description here

    Error Output:

    Compiler Error Message: CS0446: Foreach can not perform actions on a 'method group'. Did you want to call 'method group'?

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 08:16
    Michaël Vanbrabandt
    0

    Hi Jhon,

    you are missing the .Content part again in your code:

    @foreach(var member in Model.Content.Children)
    

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 08:32
    Jhon
    0

    yes, I have changed . it is displaying error again. Can you share me, What is the mistake here

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'Umbraco.Web.PublishedContentModels.Tekst' does not contain a definition for 'GetPropertyValue'

    See output error

    enter image description here

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 08:33
    Jhon
    0

    This is my document type

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 08:37
    Michaël Vanbrabandt
    0

    Hi Jhon,

    you use the dynamics type for your node object.

    Change it to IPublishedContent then you will have the method GetPropertyValue.

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 08:52
    Jhon
    0

    yes , i am using dynamics. where should i change. I am little bit confused.Can you please tel me, where.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 08:57
    Michaël Vanbrabandt
    0

    Jhon,

    chance this line:

    dynamic node;
    

    to:

    IPublishedContent node;
    

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 09:17
    Jhon
    0

    Thank you. it is coming output but it is displying wrong .

    Can you please look at my output.

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 09:21
    Michaël Vanbrabandt
    0

    Hi Jhon,

    you need to add an @ before the if statement:

    @if(Model.Id == 1322) {
    

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 09:27
    Jhon
    0

    yes , if i add @ , it is displaying error

    Compiler Error Message: CS1061:Umbraco.Web.Models.RenderModel 'does not contain a definition for' id 'and an extension' id 'was not found that accepts a first argument of the type' Umbraco.Web.Models.RenderModel '(do you need a' using ' 'directive or a assembly reference?)

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 09:29
    Michaël Vanbrabandt
    0

    Jhon,

    use Model.Id where Id needs to be camelcase.

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 09:39
    Jhon
    0

    Hi,

    I have changed . again it is displaying error

    Compiler Error Message: CS0019:The operator '==' can not be used with operands of the types 'method group' and 'int'

    enter image description here

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 09:43
    Michaël Vanbrabandt
    0

    Use Model.Content.Id.

    Always remember, the Model.Content is the object that contains the current page.

    Hope this helps!

    /Michaël

  • Jhon 87 posts 162 karma points
    Apr 23, 2018 @ 09:48
    Jhon
    1

    Yes , thank you , So many difference in umbraco 4 and umbraco 7. nice forum to learn.

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Apr 23, 2018 @ 09:55
    Michaël Vanbrabandt
    0

    No problem!

    Glad you solved it.

    Have a nice day.

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft