0

I'm working with DNN 8.4.2 - My partial looks like this this:

@{
if(ViewBag.loadItem != null && ViewBag.loadItem)
{
//load my stuff
}
}

While my rendering looks like this:

@RenderPage("Shared/MyScript.cshtml",new{ loadItem = true })

But, when the page loads, i'm getting the following exception: The name 'ViewBag' does not exist in the current context.

Is there anyway I can pass in a dynamic variable to a partial rendering in DNN's razor host?

Ali Khakpouri
  • 801
  • 8
  • 24

1 Answers1

0

Found the answer! There is no ViewBagin DNN's Razor Host module since it only works with a Model. You can use PageData instead.

var loadItem = PageData["loadItem"];
    if (loadItem != null && loadItem)
    {
        //do stuff here
    }
Ali Khakpouri
  • 801
  • 8
  • 24