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
I can display an image with the code in a partial macro as follows:
@inherits Umbraco.Web.Macros.PartialViewMacroPage @{ var vkindEventsParentPageId = Model.MacroParameters["kindEventsParentPage"]; //var vkindEventsFilter = Model.MacroParameters["kindEventsFilter"]; var vHomeNode = Model.Content.AncestorOrSelf(2); var vParentPageNode = vHomeNode; vParentPageNode = Umbraco.Content(vkindEventsParentPageId); int vCtr = 0; foreach (var vEventItem in vParentPageNode.Children) { if (vCtr == 0) { @:<div class="row clearfix"> } <div class="col-md-4 column"> <div class="panel panel-default"> @{ if (vEventItem.HasValue("logo", true)) { var mediaItem = Umbraco.TypedMedia(vEventItem.GetPropertyValue("logo", true)); <div class="panel-heading"> <div class="panel-title"> <div style="float:left; width:25%"> <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")" /> </div>
This works fine. But if I use similar code in a Partial View "Umbraco.TypedMedia is not available:
@model UmbracoWebsites.Models.kindEvents @using System; @using System.Data; @{ int vCtr = 0; foreach (DataRowView vRow in Model.kindEventsView) { dynamic vEventNode = vRow["EventNode"]; if (vCtr == 0) { @:<div class="row clearfix"> } <div class="col-md-4 column"> <div class="panel panel-default"> @{ if (vEventNode.HasValue("logo", true)) { var mediaItem = Umbraco.TypedMedia(vEventNode.GetPropertyValue("logo", true)); <div class="panel-heading"> <div class="panel-title"> <div style="float:left; width:25%"> <img src="@mediaItem.GetPropertyValue("umbracoFile")" alt="@mediaItem.GetPropertyValue("Name")" /> </div>
What am I doing wrong?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Try changing your first line to
@inherits Umbraco.Web.Mvc.UmbracoViewPage<UmbracoWebsites.Models.kindEvents>
From the section Strongly typed Partial Views https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
That should give you access to the Umbraco helper etc.
Hth
Steve
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Display an image in an MVC partial view
I can display an image with the code in a partial macro as follows:
This works fine. But if I use similar code in a Partial View "Umbraco.TypedMedia is not available:
What am I doing wrong?
Your help would be much appreciated.
Thanking you in anticipation.
Roger
Try changing your first line to
From the section Strongly typed Partial Views https://our.umbraco.org/documentation/Reference/Templating/Mvc/partial-views
That should give you access to the Umbraco helper etc.
Hth
Steve
is working on a reply...