Question

I am facing issue of web part(CEWP) provisioning in wiki page programmatically.

Web part added successfully in wiki page in display mode using below code:

 string markup = string.Format(CultureInfo.InvariantCulture, "<div class=\"ms-rtestate-read ms-rte-wpbox\" contentEditable=\"True\" ><div class=\"ms-rtestate-read {0}\" id=\"div_{0}\"></div><div style='display:none' id=\"vid_{0}\"></div></div>", new object[] { wpStorageKey.ToString("D") });

Web part property is generated perfect as we want.

but When I am going to opening in web part in edit mode to change the property . Web part is not added in edit mode.But using Contents=1 I can see web part exists in page.

I have tried below method also. Method is very helpful for me but it is generating odd even HTML which is damn complex.

WikiEditPage.InsertWebPartIntoWikiPage(existingFile, cewp, 10);

Anyone can help me out of this!! It's really a headache.

Était-ce utile?

La solution

SharePoint Object Model suggests to use WikiEditPage.InsertWebPartIntoWikiPage method for this purpose. But looks like it works incorrect: Position parameter is processed by the wrong way and you get non-working page after update.

Insert call corrupts original WikiField value because, for instance, if your position =2, you get failed HTML. Even your position=0 and Wiki page looks nice - you cannot edit it. So I don't recommend to use InsertWebPartIntoWikiPage in your work

You can write own implementation which insert new webpart in the correct place: in div with ms-rte-layoutszone-inner class.

Please check below link

http://maxshulga.blogspot.in/2010/06/wikieditpageinsertwebpartintowikipage.html

Hope you get it to work.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top