Copied to clipboard

Flag this post as spam?

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


  • dominik 711 posts 733 karma points
    Oct 18, 2012 @ 12:29
    dominik
    0

    HasValue inside foreach loop

    Hi,

    Everytime i try to use the HasValue inside a foreach loop it does not work (we are using version 4.7.2)

     foreach(dynamic item in Model.AncestorOrSelf(1).footerLinks) {

        if (item.HasValue("tooltip")) {

      do something

        }

    }

    It always show the error:

     No overload for method 'HasValue' takes '1' arguments  

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 19, 2012 @ 10:04
    Dave Woestenborghs
    0

    Is footerLinks a property or a doctype ?

     

    Dave

     

  • dominik 711 posts 733 karma points
    Oct 19, 2012 @ 10:48
    dominik
    0

    Its a property of type embedded content 

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 19, 2012 @ 10:49
    Dave Woestenborghs
    0

    What is the datatype you are using to embed the content

  • dominik 711 posts 733 karma points
    Oct 19, 2012 @ 11:22
    dominik
    0

    Datatype is an own created type which uses the render control "Embedded Content".

    Inside this embedded countent datatype i am using a content picker and a textstring ("tooltip").

     

    So what i want to do is to loop through all of the embedded content entries for footerLinks and show a tooltip if the "tooltip" textfield is filled out.

    I was able to achieve it by using 

    if(!string.IsNullOrEmpty(@item.tooltip.InnerText.ToString())) {

    But i want to use the HasValue property instead

  • dominik 711 posts 733 karma points
    Oct 22, 2012 @ 09:00
    dominik
    0

    Any idea why i cant use HasValue here?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 22, 2012 @ 09:42
  • dominik 711 posts 733 karma points
    Oct 22, 2012 @ 09:46
    dominik
    0

    Hi dawoe,

    No sorry,

    I just want to use HasValue instead of if(!string.IsNullOrEmpty(@item.tooltip.InnerText.ToString())) {

    but i am not able to achieve this

    Thanks

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 22, 2012 @ 10:01
    Dave Woestenborghs
    0

    I think you can't use HasValue because the embedded content doctype returns xml that you need to query. HasValue only works on the property of your doctype not on the properties of your embedded content

    Dave

  • dominik 711 posts 733 karma points
    Oct 22, 2012 @ 13:09
    dominik
    0

    oh ok :-( 

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft