Blockgrid layout settings
# help-with-umbraco
c
V13.1.1 In Views/Partials/Blockgrid/Components... I have an approved colour picker to pick the background colour of a layout. The below code which I've used before on another project throws up a NullReferenceException when it runs. LayoutSettings is set as the Settings Model correctly in the BlockGrid Block Configuration and I've regenerated models and rebuilt. I can't see what else is wrong.
Copy code
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockGridItem<Column2, LayoutSettings>>

@{
    string style = "style=\"";
    style += Model.Settings.BackgroundColour is not null ? "background-color: #" + Model.Settings.BackgroundColour + ";" : "";
    style += "\"";
}

<div @Html.Raw(style)>
    @await Html.GetBlockGridItemAreasHtmlAsync(Model)
</div>
If I comment out the line with Model.Settings.BackgroundColour then the page displays. Any suggestions would be appreciated. Thanks.
d
Can you share what Model.Settings.BackgroundColour is returning?
c
It's just an empty string
It's working now! God knows why. 🤦
d
Cache? Glad it's working.