If you would like to discuss anything, please contact me via email: Howard.Bayliss@sequence.co.uk

Wednesday, May 25, 2011

SharePoint "Object reference not set to an instance of an object" Page Save

I'd created a custom page layout, applied it to a page and then tried to edit the page. Everything was fine until I clicked on one of the save options for the page. At this point the site blew-up with the following stack trace:

NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.WebPartPages.WikiPageWebPartSaver.SaveWebPartsInRichText(SPWebPartManager wpmgr) +230

It took a bit of work but I tracked-down the cause. Essentially the Designer had given me some HTML mark-up which I'd pasted into the page layout. This mark-up contained an additional "form" element. When this was removed, the page-save worked correctly.


I don't remember the exact code, but it was something like the code below. The first form element is generated by SharePoint. The second form element was pasted-in by mistake.

<form id="aspnetForm" method="post" name="aspnetForm" action="default.aspx">


<form action="destination_url" method="get">