Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Is there something wrong with my code? It's bugging out at "var newRow...".
it works if I take out "<img src="@solIconImg.Url">"
var k = 1;
foreach (var solItem in CurrentPage.solutionTypeIcon)
{
IPublishedContent solIconImg = Umbraco.TypedMedia(solItem.solImage.ToString());
var newRow = (k % 2 == 0)
? "</div><div class='row'>"
: "";
<div class="col-sm-6">
<a class="learn-more" href="#">
<img src="@solIconImg.Url">
<span>@solItem.solHeading</span>
</a>
</div>
k++;
}
Thanks!
Hi NewGuy
Have you tried wrap a null check around before you call the Url property of the image?
Something like this:
var k = 1; foreach (var solItem in CurrentPage.solutionTypeIcon) { { IPublishedContent solIconImg = Umbraco.TypedMedia(solItem.solImage.ToString()); var newRow = (k % 2 == 0) ? "</div><div class='row'>" : ""; <div class="col-sm-6"> <a class="learn-more" href="#"> @if(solIconImg != null) { <img src="@solIconImg.Url"> } <span>@solItem.solHeading</span> </a> </div> k++; } }
/Bjarne
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Object reference not set to an instance of an object
Is there something wrong with my code? It's bugging out at "var newRow...".
it works if I take out "<img src="@solIconImg.Url">"
var k = 1;
foreach (var solItem in CurrentPage.solutionTypeIcon)
{
IPublishedContent solIconImg = Umbraco.TypedMedia(solItem.solImage.ToString());
var newRow = (k % 2 == 0)
? "</div><div class='row'>"
: "";
<div class="col-sm-6">
<a class="learn-more" href="#">
<img src="@solIconImg.Url">
<span>@solItem.solHeading</span>
</a>
</div>
k++;
}
}
Thanks!
Hi NewGuy
Have you tried wrap a null check around before you call the Url property of the image?
Something like this:
/Bjarne
is working on a reply...