3

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.

1 Answer 1

0

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.

1
  • Please add details to your answer so that it is useful to future readers even if the link breaks! Else it is in danger of being deleted Aug 8, 2016 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.