Copied to clipboard

Flag this post as spam?

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


  • Craig100 1078 posts 2366 karma points c-trib
    Mar 26, 2015 @ 17:03
    Craig100
    0

    Using ViewData in V7.2.2

    Structure:

    Base.cshtml
    @RenderBody()

    RenderBody outputs ProductItem.cshtml which in turn has @Html.Partial("productItemTopInfo", Model.Content)

    For a littany of reasons I have to pass a value from Base.cshtml to productItemTopInfo.cshtml. I thought of using ViewData but that didn't work. Looking on OS I saw http://stackoverflow.com/questions/27990225/how-to-use-viewdata-and-viewbag-with-umbraco-surface-controllers and on Our I saw https://our.umbraco.org/forum/developers/api-questions/36614-411-Using-SurfaceController-Child-Action-with-Post?p=2. Both seem to say you need to do a ViewData from Base.cshtml to ProductItem.cshtml, pick it up and apply it again to ViewData so it can be picked up at productItem.cshtml.

    None of the above works. Am I doing it wrong, is there a better way with Umbraco?

    Thanks,

    Craig

  • Craig100 1078 posts 2366 karma points c-trib
    Mar 27, 2015 @ 01:58
    Craig100
    0

    Cache.Insert("my key name", "myValue");

    var myNewValue = (string)Cache["my key name"];

    .....was the answer, nothing to do with Umbraco (I think).

    Hope this helps someone else.

    Craig

     

  • 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