@{
var nodes = umbraco.uQuery.GetNodesByName("Nyheder");
if (nodes.Any())
{
IPublishedContent node = Umbraco.TypedContent(nodes.First().Id);
var children = node.Children().Where("Visible");
var selection = children.OrderBy("CreateDate desc");
int counter = 0;
foreach (var item in selection)
{
DateTime startDate = DateTime.Parse(@item.GetPropertyValue("publishedFrom").ToString());
DateTime endDate = DateTime.Parse(@item.GetPropertyValue("publishedTo").ToString());
string author = @item.GetPropertyValue("CreatorName").ToString();
if ((startDate <= DateTime.Now) && (endDate > DateTime.Now))
{
<div class="panel panel-default">
<div class="panel-heading">
@item.GetPropertyValue("NyhedOverskrift")
</div>
<div class="panel-body">
@item.GetPropertyValue("nyhedsIndhold")
</div>
</div>
counter++;
}
if (counter > 2)
{
break;
}
}
}
}
When I remove the line with "author" it works fine.
When I add it, it breaks in the file genereated by Umbraco (\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\b57d6c43\a8a0a4ec\AppWebhomepage.cshtml.65a2d1ee.tz2gnzwb.0.cs) with an error CS1513: } was expected.
I simply can't figure out what is wrong, but my guess is that is maybe has something to do with the nested divs or an error in Umbraco :-)
Thanks for the advise, Dave - Made me understand was really was the problem :-)
Removing the '@' signs made it come up with an "null reference" error.
This made me realize that I did not have a property called 'CreatorName' but it actually was a build in property, so I didn't need the GetPropertyValue for this.
Error CS1513: } in Umbraco generated file
Hi
I have the following code snippet
When I remove the line with "author" it works fine. When I add it, it breaks in the file genereated by Umbraco (\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\b57d6c43\a8a0a4ec\AppWebhomepage.cshtml.65a2d1ee.tz2gnzwb.0.cs) with an error CS1513: } was expected.
I simply can't figure out what is wrong, but my guess is that is maybe has something to do with the nested divs or an error in Umbraco :-)
Can anyone shed some light on this, please?
Hi Arly,
Can you change this line :
to this
Dave
I may have todo with the "@" signs you use where not needed:
Try removing them. If the error keep coming up, then try to delete the temporary file causing the error.
Hi
Thanks for the advise, Dave - Made me understand was really was the problem :-)
Removing the '@' signs made it come up with an "null reference" error. This made me realize that I did not have a property called 'CreatorName' but it actually was a build in property, so I didn't need the GetPropertyValue for this.
Once corrected, evertyhings working :-)
Thanks again
Hi
Also thanks to you Casper - You both nailed it :-)
is working on a reply...