Frage

I have created a simple custom calendar list using a sandboxed solution. I want to use recurring event, but that's not working with my created list, it's showing me an error message.

I am getting the error message as below

Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: Value does not fall within the expected range.
at Microsoft.SharePoint.WebControls.RecurrenceField.SetRecurrenceFields()
at Microsoft.SharePoint.WebControls.RecurrenceField.CompleteItemLoad()
at Microsoft.SharePoint.WebControls.SaveButton.ActionBeforeSaveItem(SPContext itemContext)
at Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment)
at Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


code i have added in event recievere file is as like bellow spinet

enter image description here

and after this i am an adding feature id of site level feature in element.xml file of the list instance,after that i am rebuilding solution,publishing it and then uploading that published .wsp file in SharePoint using solution gallery and after that simple activating the site level feature that's it

War es hilfreich?

Lösung

Please check below image for reference

enter image description here

Instead of creating the calendar through a feature element, You have to user c# code to create Calendar list from Event Receiver.

You can use below mentioned code in your FeatureActivated class in your feature event receiver.

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {


                SPSite site = new SPSite(SPContext.Current.Site.ID);
                SPWeb web = site.OpenWeb(SPContext.Current.Web.ID);
                SPList listExistCheck = web.Lists.TryGetList("Calendar List");
                SPList customList;
                if (listExistCheck == null)
                {
                    // Create calendar list and record returned guid
                    Guid customPagesListGuid = web.Lists.Add("Calendar List", "Calendar List", SPListTemplateType.Events);
                    //Get list from stored guid
                    customList = web.Lists[customPagesListGuid];
                    // Set list properties and add required content types

                    customList.Title = "Calendar List";
                    customList.OnQuickLaunch = true; // Set to true to display on the quick launch
                    customList.ContentTypesEnabled = true;
                    customList.Update();
                    customList.Update();
                    web.Update();
                }

        }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange
scroll top