We are using SPCalendarView inside a custom web-part to show events. I am now trying to implement a new functionality to show various calenders for different locations (e.g NYC, London, New Delhi etc.).
Here is the code snippet:
SPCalendarView calendarView; calendarView.DisplayItemFormUrl = SPContext.Current.Web.Lists["Calendar"].DefaultDisplayFormUrl; calendarView.ViewGuid = list.Views["All Events"]; calendarView.ListName = web.Lists["Calendar"].ID.ToString(); SPCalendarDataSource o = new SPCalendarDataSource(); o.List = SPControl.GetContextWeb(HttpContext.Current).Lists[new Guid(list.ID.ToString())]; o.View = o.List.GetView(new Guid(list.Views["All Events"].ID.ToString())); calendarView.RegionalSettings.TimeZone.ID = 2 //(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London calendarView.DataSource = o; DataBind(); this.Controls.Add(calendarView);
On page refresh, everything is working just fine and calendar is showing all events based on London timezone.
Problem is when user clicks on "Next Day" button of the calendar, SPCalendarView looses this TimeZone value and instead it picking up User's timezone. In Firebug I can see SPCalendarView is making AJAX call to http://sp/_layouts/CalendarService.ashx to fetch events for the next day and hence I lose the timezone value set.
So my questions are: 1. Is it really possible in SharePoint to set timezone of SPCalendarView through code which also work with next/prev days click events. 2. If not, then can I change next/prev day click event to call my own web service instead? 3. If not, then is it possible to post back the page on next/prev days click events in SPCalendarView control?
Thank you in advance for your help. Please do post your reply even if you have any other workaround to fix this issue.
[UPDATE] Here is SPCalendarView's AJAX call
POST Url: http://sp/_layouts/CalendarService.ashx Parameters: cmd=query&listName=275ae3d1-db66-4337-8be5-3f65ca17ee72&viewName=4e09a90d-4c36-4d5b-b0a6-5a1a43d23e09&dataSourceId=00000000-0000-0000-0000-000000000000&viewType=day&entity=0;#0&selectedDate=2/2/2012&options=47