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 6132 posts 23951 karma points MVP 7x 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?

Please Sign in or register to post replies

Write your reply to:

Draft