I'm struggling abit with my razor code here. I have a collection of node which each has a DatePicker. In Razor I want to compare the selected day (and only day) to the current day.
I've tried to loop through with a .Where() predicate, but there's just no way it will work. This is my code:
var calendarRoot = Model.NodeById(1059); foreach(var item in calendarRoot.Children.Where("item.eventDate.Day = 20")) { <span>@item.eventDate</span> }
And this is the error I get when I run it:
Error loading Razor Script Rendercalendar.cshtml
No property or field 'eventDate' exists in type 'Func`2'
Anyone got any hints about this? :-) Will be greatly appreciated!
@{ var calendarRoot = Model.NodeById(1059); foreach(var item in calendarRoot.Children.Where("eventDate > DateTime.Now")) { <span>@item.eventDate</span> } }
O.k the above code works as intended, it gives me all the nodes where the selected date is greater than today. Just can't figure out how to get hold of evenDate.Day <- the daynumber.
Compare date from DatePicker datatype
Hi all,
I'm struggling abit with my razor code here. I have a collection of node which each has a DatePicker. In Razor I want to compare the selected day (and only day) to the current day.
I've tried to loop through with a .Where() predicate, but there's just no way it will work. This is my code:
var calendarRoot = Model.NodeById(1059);
foreach(var item in calendarRoot.Children.Where("item.eventDate.Day = 20"))
{
<span>@item.eventDate</span>
}
And this is the error I get when I run it:
Error loading Razor Script Rendercalendar.cshtml
No property or field 'eventDate' exists in type 'Func`2'
Anyone got any hints about this? :-) Will be greatly appreciated!
/ Bo
try .Where("calendarRoot.eventDate.Day = 20")
Hi Toni,
Thanks for your input! :-)
I tried it, but since there is no datatype on the calendarRoot called evenDate i get the following error:
Error loading Razor Script Rendercalendar.cshtml
No property or field 'eventDate' exists in type 'Func`2'
:-/
Thanks again!
/ Bo
@{
var calendarRoot = Model.NodeById(1059);
foreach(var item in calendarRoot.Children.Where("eventDate > DateTime.Now"))
{
<span>@item.eventDate</span>
}
}
O.k the above code works as intended, it gives me all the nodes where the selected date is greater than today. Just can't figure out how to get hold of evenDate.Day <- the daynumber.
Did you find a solution for your Problem?
i'm struggling with the "same" thing. just have to check the if there is an event at an certain date an then display the date.
Andi
Hi,
Here's one way - it's not "pretty" but works:
is working on a reply...