Link to home
Start Free TrialLog in
Avatar of websss
websssFlag for Kenya

asked on

update viewbag item in layout.cshtml from partial view

Hi

I have a site that loads different logos etc depending on the URL you enter on


I have the following areas in a _Layout.cshtml file

<title>@ViewBag.PageTitle </title>
   <img id="logo" src="@ViewBag.Logo" />

       <span class="txt-color-white">@ViewBag.Footer</span>

Open in new window


then in the controller I populate these
     ViewBag.Logo = site.BrandingLogo;
                ViewBag.Title = site.BrandingPageTitle;
                ViewBag.Footer = site.BrandingFooter;

Open in new window



This all works fine for these
 
public ActionResult Index()
  ..
 return View();

Open in new window



However its not working for this

public ActionResult LoadGraph(string GroupId)
..
return PartialView(model);

Open in new window


I assume because its a partial view and not a view?


Can you suggest a way to get this working with a paritial view

Or better yet do this population of the layout in one place rather than every view for different pages?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.