I've got a surface controller that calls an external api to get a list of stores in a given city and state. The problem is I need to use some data that I get back from that call in the
<title></title>
Which exists in the head of my Master Template. As far as I can tell there's no way to pass data up from a partial view into the Master Template. I'm stumped.
I tried using ViewBag but it renders the head before my partial view sets the value and it just comes up null.
Template:
<head>
<title>ViewBag.Title</title>
</head>
<body>
<div class="main foreground container">
<h1>@CurrentPage.title</h1>
@CurrentPage.mainColumn
@Html.Action( "StoreDirectory", "Locations" )
</div>
</body>
Partial View:
@model Fromm.Web.Consumer.Models.StoreDirectoryModel
@using Fromm.Model;
@{
ViewBag.Title = @Model.Title;
}
This is not really umbraco related because you would have the same problem when you invoke an ChildAction from a template when you would be using plain MVC.
The only way to solve this is using a MvcRenderController for your complete template, rather then a surfaceController.
Then... If the titletag is specified in the master document make it overridable in the templates using a section: