Friday, April 6, 2012

Open SharePoint Calendar overlay events in modal dialog

I have calendar control with calendar overlays in a page to show calendar events to end-user. All calendar overlay events opens in a new window. But my client wanted to open those events in modal dialog, not in new window.

Then I used the below code in my page(where calendar control presents) using content editor webpart.

// load our function to the delayed load list
_spBodyOnLoadFunctionNames.push('calendarEventLinkIntercept');

// hook into the existing SharePoint calendar load function.
function calendarEventLinkIntercept()
{
if (SP.UI.ApplicationPages.CalendarNotify.$4a)
{
var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4a;
SP.UI.ApplicationPages.CalendarNotify.$4a = function ()
{
OldCalendarNotify();
bindEventClickHandler();
}
}
if (SP.UI.ApplicationPages.CalendarNotify.$4b)
{
var OldCalendarNotify = SP.UI.ApplicationPages.CalendarNotify.$4b;
SP.UI.ApplicationPages.CalendarNotify.$4b = function ()
{
OldCalendarNotify();
bindEventClickHandler();

}
}
// future service pack change may go here!
// if (SP.UI.ApplicationPages.CalendarNotify.???)
}

function bindEventClickHandler() {
$('.ms-acal-rootdiv a').click(function(){EditLink2(this,'WPQ2');return false;});
}


All overlay were opening in modal dialog :) [Just copy and paste the code]

Note: Find your calendar control's 'WPQ#' and replace the 'WPQ2' in bindEventClickHandler() with your 'WPQ#'. For some control the number changes. Ex: If you control with 'WPQ3' then replace 'WPQ2' with 'WPQ3' in bindEventClickHandler(). You can find that number in status bar of your browser on mouse over the month changing arrows.

Wednesday, March 28, 2012

Anonymous access to SharePoint 2010 list forms

You could have faced a strange issue when accessing SharePoint 2010 list forms on anonymous access. I have a Publishing Site with FBA authentication. I was using calendar control with overlays to display the events to all users. calendar control uses "DispForm.aspx" to display the event details to the user. But when anonymous users click on the Title, the page redirects to the Login form.

Its the problem with ViewFormPagesLockdown.

To overcome this problem, I executed the below code in PowerShell;

To determine if a site has ViewFormPagesLockdown enabled run the following:

get-spfeature -site http://sitecollectionURL

If ViewFormPagesLockDown is listed, it's enabled.


$lockdown = get-spfeature viewformpageslockdown

disable-spfeature $lockdown -url http://sitecollectionURL


If anonymous is already setup, you may need to disable\re-enable anonymous on the site.


Happy Coding :)


Sunday, March 25, 2012