lundi 26 janvier 2015

Iframe an ApplicationPage



I have an iframe that frames in a SharePoint 2013 custom page that includes <WebPartPages:AllowFraming runat="server" />. On the custom page it has a Document Library webpart with no navigation. I have created some javascript and a button that mimics the upload file.



var list, listRootFolder, listID, parser, pathArray, path;
ExecuteOrDelayUntilScriptLoaded(init, "sp.js");

function init() {
var currentcontext = new SP.ClientContext.get_current();
list = currentcontext.get_web().get_lists().getByTitle('Documents');
listRootFolder= list.get_rootFolder();
currentcontext.load(list, 'Id');
currentcontext.load(listRootFolder);
currentcontext.executeQueryAsync(Function.createDelegate(this, result), Function.createDelegate(this, oncListQueryFailed));
}
function result() {
listID = list.get_id();
console.log(listID);
parser = document.createElement('a');
parser.href = document.URL;
pathArray = parser.pathname.split("/");
path = "/" + pathArray[1] + "/" + pathArray[2] + "/";
path = path + '_layouts/15/CUSTOM/Upload.aspx?List=%7B' + listID + '%7D&RootFolder=' + path + 'Shared Documents&Source=http://ift.tt/1vSmqjN' + path + 'SitePages/Home.aspx';
//setOnclick;
}
function oncListQueryFailed(sender, args) {
console.log('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
function setOnclick(){
document.getElementById('uploadBtn').onclick=function(event){EditItem2(event, path);};
}
window.onload = setOnclick;


<a href="#" id="uploadBtn">
Upload
</a>


I have copied the upload.aspx and placed it into our custom Layouts folder on the server. I can reference it and it works as it should when I am directly on the page. The problem is I can not iframe in the upload.aspx page. I have tried adding <WebPartPages:AllowFraming runat="server" /> but it does not work. Comparing the upload page to the custom aspx page we created I am able to see some differences.


The upload page has an assembly name of Microsoft.SharePoint.ApplicationPages where the custom page is Microsoft.SharePoint. There were other differences but everything seems to be around the ApplicationPages.


How can I convert the upload.aspx page to a webpart part page or frame in an application page.








0 commentaires:

Enregistrer un commentaire