Here is the sample peace of code to create wiki pages libary in sharepoint
public void CreateWikiPagesLibray(SPWeb web) { try { // SPList list = web.Lists.TryGetList("Site Pages"); SPList list = web.Lists.TryGetList("EID"); if (list == null) { SPListTemplate template = web.ListTemplates["Wiki Page Library"]; Guid listID = new Guid(); listID = web.Lists.Add("EID", "", template); list = web.Lists[listID]; list.OnQuickLaunch = true; list.Update(); } } catch (Exception ex) { throw new SPException(ex.ToString()); } }
This is the code to create wiki page in library
public void CreateWikiPage(SPList list, string pageTitle, int layoutTemplate) { try { SPFolder rootFolder = list.RootFolder; SPFile wikiPage = rootFolder.Files.Add(String.Format("{0}/{1}", rootFolder.ServerRelativeUrl, pageTitle), SPTemplateFileType.WikiPage); SPListItem wikiItem = wikiPage.Item; //wikiItem[SPBuiltInFieldId.WikiField] = "My Wiki Page with [[wiki link]]"; wikiItem.UpdateOverwriteVersion(); } catch (Exception ex) { throw new SPException(ex.ToString()); } }
Thank you !!!
No comments:
Post a Comment