Copied to clipboard

Flag this post as spam?

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


  • Ian Grainger 71 posts 135 karma points
    Feb 18, 2013 @ 13:31
    Ian Grainger
    0

    Razor/Linq Can't use string.Split?

    Hi - I have a select statement:

    @Model.AncestorOrSelf().Descendants("Staff").Where("Office.Split(',').Contains(\"London\")")

    Which is giving me the error: No applicable method 'Split' exists in type 'String'

    Which is very weird because the string.Contains method does seem to exist, so:

    .Where("Office.Contains(\"" + @Model.Name + "\")")

    Works fine - but isn't quite what I'm after!

  • gary 385 posts 916 karma points
    Feb 18, 2013 @ 14:04
    gary
    0

    Hi Ian

    Just came across something similar, think it's your @Model, changed to @CurrentPage and problem solved.

    Guess it will depend on which version, but should give you a direction.

    Regards G

  • Ian Grainger 71 posts 135 karma points
    Feb 18, 2013 @ 14:58
    Ian Grainger
    0

    Thanks for the reply gary, but not sure how to use CurrentPage! 

    @Model.CurrentPage.AncestorOrSelf().Descendants("Staff").Where("Office.Split(',').Contains(\"London\")")

    Gives me an error: Cannot implicitly convert type 'umbraco.MacroEngines.DynamicNull' to 'umbraco.MacroEngines.DynamicNodeList' But I'm guessing that's not what you were suggesting?

    This is on umbraco v 4.11.1 (Assembly version: 1.0.4715.27659) BTW.

     

     

     

     

     

     

     

  • gary 385 posts 916 karma points
    Feb 18, 2013 @ 15:04
    gary
    0

    Hi Ian

    Apologies, didn't mean to confuse.

    I use Umbraco in Mvc as opposed to webforms (the calls are slightly different).

    But you should be able to use @CurrentPage.AncestorOrSelf() etc.

    If you get any more errors, post the version ie Mvc Razor or Webforms razor and I'm sure you will have an answer.

    Regards G

  • Ian Grainger 71 posts 135 karma points
    Feb 18, 2013 @ 15:06
    Ian Grainger
    0

    Ah, OK.

    The error is in a Razor macro script (cshtml file), as I say I'm running umbraco v 4.11.1 (Assembly version: 1.0.4715.27659).

Please Sign in or register to post replies

Write your reply to:

Draft