mercredi 25 mars 2015

Get a webpart in the webpart gallery



I am trying to get a webpart from the gallary to add to a webpart page. It fails on the GetFile line saying that it can't find the file but the file is in the gallary. Is the code/path correct?



SPFile myWebPart = newSite.RootWeb.GetFile(newSite.RootWeb.Url + "/_catalogs/wp/UserQuestionnaireSummaryWebPart.webpart");
XmlTextReader read = new XmlTextReader(myWebPart.OpenBinaryStream());
var wp = manager.ImportWebPart(read, out errMsg);
manager.AddWebPart(wp, null, 1);
manager.SaveChanges(wp);







0 commentaires:

Enregistrer un commentaire