webjaved
07/26/2023, 10:54 AM@using Umbraco.Core.Models.Blocks
@inherits UmbracoViewPage<BlockListItem<TitleBlock>>
@{
var settings = (TitleBlockSettings)Model.Settings;
if(!settings.HasImageOrSubtext) {
<p>something here</p>
}
}
<section id="sd-wan-info" class="title block longer has-image eo">
<div class="inner">
<div class="text-part">
<h1>@Model.Content.TitleHeading<br></h1>
<div class="subtitle" style="color: #0F2C43">
@Model.Content.TextContent
</div>
</div>
<div class="image-part">
<img width="362" height="348" src="@Model.Content.TitleBlockImage.MediaUrl()" alt="@Model.Content.BlockImageAlternativeText" class="attachment-full size-full" loading="lazy">
</div>
</div>
</section>
Here are the settings for the block: https://prnt.sc/1nhUPgzY9N-Z
The settings model has been selected in the data models section: https://prnt.sc/DQN1KzEO8CcX
This is the error that I am getting: System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.NullReferenceException: 'Object reference not set to an instance of an object.'
settings was null.
I'm not sure where I am going wrong here.Matt Wise
07/26/2023, 11:03 AMMatt Wise
07/26/2023, 11:03 AM@inherits UmbracoViewPage<BlockListItem<TitleBlock, TitleBlockSettings>>
webjaved
07/26/2023, 11:08 AM@if(HasImageOrSubtext){ /* code here */ }
Matt Wise
07/26/2023, 11:11 AMMatt Wise
07/26/2023, 11:11 AMMatt Wise
07/26/2023, 11:12 AMwebjaved
07/26/2023, 11:16 AM