@model TextOverImage.Models.ImageWithText
@{
// Use this code to render this partial in your template. Replace "banner" with whatever your property name is
// Make sure to include @using TextOverImage.Models at the top of your template
//@if(Model.Content.HasProperty("banner") && Model.Content.HasValue("banner"))
//{
// @Html.Partial("TextOverImagePartial", Model.Content.GetPropertyValue<ImageWithText>("banner")
//}
// You could use banner.Media.GetCropUrl(width,height) here instead if you want to set it!
var imageUrl = Model.Media != null ? Model.Media.Url : string.Empty;
// Only render the style tag if the image url exists
var style = !string.IsNullOrEmpty(imageUrl) ? MvcHtmlString.Create(" style=\"background: url(" + imageUrl + ") no-repeat center center; background-size: cover;\"") : MvcHtmlString.Empty;
}
<div class="banner [email protected]"@style>
<div class="banner--inner [email protected]">
<h1>@Model.Headline</h1>
<h2>@Model.Subheadline</h2>
@if (Model.Link != null)
{
<a href="@Model.Link.Url" target="@Model.Link.Target" class="button">@Model.Link.Name</a>
}
</div>
</div>
Although it was missing a closing paren (which I added).
When you do not specify a model, the model for the parent context gets used, which will not work in this case. I think passing null has the same effect.
Text over image Editor [email protected]
I am getting this error with the partial
Has anyone else run into this?
You have not passed a model in when you rendered the partial:
The code you pasted actually shows what you should be doing:
Although it was missing a closing paren (which I added).
When you do not specify a model, the model for the parent context gets used, which will not work in this case. I think passing null has the same effect.
I think this is called read the code!!!
is working on a reply...