Tag Archives: Custom Action

Invoke server side code on SharePoint custom ribbon button in background

It is happen to be SP2010 and above not allowing Custom Ribbon Actions not allowed to have ControlAssembly and ControlClass to execute server side code (which happen to be in SP2007).  By the way this is possible with some other locations like context menu even with SP2010.

But there are few workarounds that can make up to this. Three of such workarounds have being clearly showcased by Naddem Yousuf on his blog. However I wanted to have a button which will trigger a update in background while the user remains on the List Form. So I used Nadeem’s 1st option with slight modification to JS event handler. Here is my modification.

    var iframe = document.createElement(“iframe”);
    iframe.setAttribute(“style”, “display:none”);
    iframe.setAttribute(“name”, “hiddeniFrame”);

    var form = document.createElement(“form”);
    form.setAttribute(“method”, “post”);
    form.setAttribute(“action”, pageUrl);
    form.setAttribute(“target”, “hiddeniFrame”);

Here I am creating a hidden iframe and using it as the target of the form so that everything from the control response will be hidden from the form.