Copied to clipboard

Flag this post as spam?

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


  • Eli 15 posts 95 karma points
    Apr 02, 2019 @ 23:51
    Eli
    0

    Share variable from master layout to children

    Hi,

    I am looking for the best way to set a variable in the master layout, and then access it in all of its children. I tried ViewBag but it didn't work.

    Cheers Eli

  • Alex Skrypnyk 6182 posts 24284 karma points MVP 8x admin c-trib
    Apr 03, 2019 @ 00:23
    Alex Skrypnyk
    1

    Hi Eli

    You can pass data as a model to a partial view from the master template.

    Thanks,

    Alex

  • Eli 15 posts 95 karma points
    Apr 03, 2019 @ 00:35
    Eli
    0

    Hi Alex. Thanks.

    But I render the child as RenderBody() and not as a partial view. Is there a way to share the variable with it?

  • 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