Saturday, March 21, 2009

SharePoint Wiki Coding

Another pitfall!
Recently i was faced with a task of retrieving data from a WSS 3.0 wiki page to be used in some WebPart and discovered quite a few interesting things; Unlike other lists/folders a wiki has some special considerations in order to access its content.
An obvious approach was using the SPWeb object to retrieve the list item as;

SPListItem item = web.Folders[""].Files[]

Here the actual contents of the item is the aspx template used by the wiki page.
A wiki like other files has properties and you will need the [Wiki Field] property to access actual page contents to a string variable.

string wikiContent = item.Properties["Wiki Field"].ToString();

and you got it.

No comments:

Post a Comment