Technical support This forum is closed.
Version 1.x > Technical support > CMSCalendar control error View modes: 
User avatar
Member
Member
forrester - 6/29/2006 12:30:31 AM
   
CMSCalendar control error
I am using the CMSCalendar control on 1.9/C#/VS2003. It works fine on another site that I did, but on the current site I am getting an error.

#############################
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0118: 'Kentico.CMS.CMSControls.DataCalendarItem.DataItem' denotes a 'property' where a 'method' was expected

Source Error:



Line 53: <ItemTemplate>
Line 54: <br />
Line 55: <a href='<%# ResolveUrl("~" & Container.DataItem("AliasPath"))%>'>
Line 56: <%# Container.DataItem("NewsTitle")%>
Line 57: <br />


Source File: c:\inetpub\wwwroot\KCMS\calendar.aspx Line: 55
###############################

I have followed the steps in the Developer's Guide by adding the following properties:
DayField = "NewsReleaseDate"
SelectNodesClassName = "cms.news"
SelectNodesPath = "/%"
SelectNodesPathType = AliasPath

The only difference between this site and my last site is that the last site only had one menu level. The current site has two levels as follows.

Home
- Calendar
News
Contact
etc.

The Calendar.aspx page is one level under Home and News.aspx is on the main level from where the calendar show pull the news.

I hope this is detailed enough. Your help is appreciated.

Thanks,
forrester

User avatar
Member
Member
forrester - 6/29/2006 5:38:11 PM
   
Re: CMSCalendar control error
I should add that the control does not throw the error when I remove the <ItemTemplate> code. I have also tried putting the News.aspx and Calendar.aspx on the same path level.

forrester

User avatar
Member
Member
forrester - 6/29/2006 7:55:47 PM
   
[RESOLVED] Re: CMSCalendar control error
I found the problem which stems from a typo in the Developer's Guide > Using Kentico CMS Controls > CMSCalendar

As stated before, I followed the steps in the guide:

##############################

Example

This example will show you how to display a calendar with news items released on particular date.

Create a new Web form.

Drag and drop the CMSCalendar control on the form.

Set the following properties - they specify what should be displayed.

DayField = "NewsReleaseDate"
SelectNodesClassName = "cms.news"
SelectNodesPath = "/%"
SelectNodesPathType = AliasPath

Switch to the HTML mode and add the following code inside the BasicCalendar element. The ItemTemplate section specifies the look of the event that will be displayed in the calendar control. The NoEventsTemplate section specifis the look of the day without any event.

[VB.NET]

<ItemTemplate>
<br />
<a href='<%# ResolveUrl("~" & Container.DataItem("AliasPath"))%>'>
<%# Container.DataItem("NewsTitle")%>
<br />
</a>
</ItemTemplate>
<NoEventsTemplate>
<br>
No Event
</NoEventsTemplate>

[C#]

<ItemTemplate>
<br />
<a href='<%# ResolveUrl("~" & Container.DataItem("AliasPath"))%>'>
<%# Container.DataItem("NewsTitle")%>
<br />
</a>
</ItemTemplate>
<NoEventsTemplate>
<br>
No Event
</NoEventsTemplate>

#############################

After I looked at it again and compared it with the code on Developer's Guide > Using Kentico CMS Controls > BasicCalendar, I realized the C# code (above) is the same as the VB.NET code on the CMSCalendar example. I changed the syntax accordingly and now it works just fine.

I forgot that the other site that I did was in VB.NET, not C#...which explains why it worked and this one didn't.

forrester

User avatar
Guest
admin - 7/4/2006 8:06:27 AM
   
Re: [RESOLVED] Re: CMSCalendar control error
Hello,

I'm sorry for the typo, we will fix it in the nearest update.

Best Regards,