I have a custom Pagelayout, I wan't to add a EventList and will show the Calendar View for this.

But when I use the follwing code in the custom pagelayout it only show a plain list.

<WebPartPages:XsltListViewWebPart ID="calendarmaintenance" runat="server" ListUrl="Lists/ServiceCalendar" IsIncluded="True" NoDefaultStyle="TRUE" Title="Public Documents" PageType="PAGE_NORMALVIEW" FrameType="None" Default="False" ViewContentTypeId="0x">
        <View BaseViewID="2" Type="CALENDAR" WebPartZoneID="Main" DisplayName="$Resources:core,userinfo_schema_calendarview;" MobileView="TRUE" MobileDefaultView="TRUE" 
            SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/events.png?rev=23" TabularView="FALSE" Url="calendar.aspx" RecurrenceRowset="TRUE" DefaultView="TRUE" 
            <Toolbar Type="None" />
                <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
                <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
                <FieldRef Name="Location" Type="CalendarWeekLocation"/>


I also Tried to adding a ListViewWebpart onto the Page in a webpart zone with follwing code:

   ListViewWebPart calendar = new ListViewWebPart();
calendar.ListId = list.ID;
foreach (SPView view in list.Views)
    if (view.Url.ToString().Contains(urlviewpagename))
        SharePointLogger.Log($"Found view {urlviewpagename}");
        calendar.ID = Guid.NewGuid().ToString("B").ToUpperInvariant();
        calendar.ViewGuid = view.ID.ToString("B").ToUpperInvariant();
calendar.ChromeState = PartChromeState.Normal;
calendar.ChromeType = PartChromeType.TitleOnly;
SharePointLogger.LogInformation($"Adding {list.Title} to zone {zoneid}");
webpartManager.AddWebPart(calendar, zoneid, 0);

This dispaly the Calendar but it does throw many javascript exceptions and I also have a deactivated ribbon bar to. What do I wrong? :(


Solved my problem. I used a guid with dashes and this won't work. I replaced this wit Guid.ToString("n") tomged a guid without dashes and after that it worked well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.