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
Hi,
Currently I'm struggling to check if a documenttype (member) has a 'damp' image property:
@{ var membersToList = @Model.Children.Where("Visible"); <table> @foreach (var memberGroup in membersToList.InGroupsOf(3)) { <tr> @foreach (dynamic member in memberGroup) { <td style="padding:10px;"> @{ if(member.HasValue("memberImage")) { var image = member.memberImage.mediaItem.MemberImage.umbracoFile; } } @if (image != null) { <img src="/imageGen.ashx?image=@image&width=150" style="margin-bottom:10px;"/><br /> } else { <img src="/imageGen.ashx?image=/media/1591/mystery-person.jpg&width=150" style="margin-bottom:10px;"/><br /> } @(member.memberFirstName + " " + member.memberLastName) </td> } </tr> } </table> }
The problem is that I don't have any method on a dynamic type to check for the existence of a documenttype property. So I can't do for instance: if (member.HasValue("memberImage").Value != ""))
Does anyone know I solution for this?
Thanks for your help,Anthony
I found the solution, this works:
@{ var membersToList = @Model.Children.Where("Visible"); <table> @foreach (var memberGroup in membersToList.InGroupsOf(3)) { <tr> @foreach (dynamic member in memberGroup) { <td style="padding:10px;"> @{ var image = ""; if(member.memberImage.ToString() != "") { image = member.memberImage.mediaItem.MemberImage.umbracoFile; } } @if (image != "") { <img src="/imageGen.ashx?image=@image&width=150" style="margin-bottom:10px;"/><br /> } else { <img src="/imageGen.ashx?image=/media/1591/mystery-person.jpg&width=150" style="margin-bottom:10px;"/><br /> } @(member.memberFirstName + " " + member.memberLastName) </td> } </tr> } </table> }
greetings,
Anthony
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
how to check for documenttype property on a dynamic type
Hi,
Currently I'm struggling to check if a documenttype (member) has a 'damp' image property:
@{
var membersToList = @Model.Children.Where("Visible");
<table>
@foreach (var memberGroup in membersToList.InGroupsOf(3))
{
<tr>
@foreach (dynamic member in memberGroup)
{
<td style="padding:10px;">
@{
if(member.HasValue("memberImage"))
{
var image = member.memberImage.mediaItem.MemberImage.umbracoFile;
}
}
@if (image != null)
{
<img src="/imageGen.ashx?image=@image&width=150" style="margin-bottom:10px;"/><br />
}
else
{
<img src="/imageGen.ashx?image=/media/1591/mystery-person.jpg&width=150" style="margin-bottom:10px;"/><br />
}
@(member.memberFirstName + " " + member.memberLastName)
</td>
}
</tr>
}
</table>
}
The problem is that I don't have any method on a dynamic type to check for the existence of a documenttype property. So I can't do for instance: if (member.HasValue("memberImage").Value != ""))
Does anyone know I solution for this?
Thanks for your help,
Anthony
I found the solution, this works:
@{
var membersToList = @Model.Children.Where("Visible");
<table>
@foreach (var memberGroup in membersToList.InGroupsOf(3))
{
<tr>
@foreach (dynamic member in memberGroup)
{
<td style="padding:10px;">
@{
var image = "";
if(member.memberImage.ToString() != "")
{
image = member.memberImage.mediaItem.MemberImage.umbracoFile;
}
}
@if (image != "")
{
<img src="/imageGen.ashx?image=@image&width=150" style="margin-bottom:10px;"/><br />
}
else
{
<img src="/imageGen.ashx?image=/media/1591/mystery-person.jpg&width=150" style="margin-bottom:10px;"/><br />
}
@(member.memberFirstName + " " + member.memberLastName)
</td>
}
</tr>
}
</table>
}
greetings,
Anthony
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.