2

Here I want to create a URL of a Event(s) of sharepoint calendar list in c#. For that I am using the DefaultDisplayFormUrl as per my below code.

foreach (SPListItem item in listItems)
{
    DateTime startDate = DateTime.Parse(item[StartDateField].ToString().Trim());
    string fullUrl = "";
    var itemId = "?ID=" + item.ID;
    if (item[RecurrenceField].ToString() == "True")
    {
        string eventURL = "0";
        if ((int)item[EventTypeField] == 4)
        {
            eventURL = ".1." + item[SeriesIdField];
        }
        else
        {
            SPRegionalSettings oRegionalSettings = web.RegionalSettings;
            SPTimeZone oTimeZone = oRegionalSettings.TimeZone;
            int dtHour = startDate.Hour;
            int dtMinute = startDate.Minute;
            int dtSecond = startDate.Second;
            bool isAllDayEvent = Convert.ToBoolean(item["fAllDayEvent"]);
            if (isAllDayEvent)
            {
                dtHour = 0;
                dtMinute = 0;
                dtSecond = 0;
            }
            var dtDateNew = new DateTime(startDate.Year, startDate.Month, startDate.Day,
                dtHour, dtMinute, dtSecond);
            DateTime utcDate = oTimeZone.LocalTimeToUTC(dtDateNew);

            if (isAllDayEvent)
            {
                utcDate = dtDateNew;
            }
            eventURL = ".0." + String.Format(
                "{0:yyyy-MM-ddTHH:mm:ssZ}",
                utcDate);
        }
        fullUrl =
            item.ParentList.ParentWeb.Site.MakeFullUrl(item.ParentList.DefaultDisplayFormUrl +
                                                       itemId + eventURL + "&Source=" + returnUrl);
    }
    else
    {
        fullUrl =
            item.ParentList.ParentWeb.Site.MakeFullUrl(item.ParentList.DefaultDisplayFormUrl +
                                                       itemId + "&Source=" + returnUrl);
    }
}

bet here I am getting the exception which is not allowing me create the complete URL. can anyone help with this?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.