"The security validation for this page is invalid" error when updating objects through SharePoint object model

This error is often encountered when SharePoint OM is used to update site/web/list objects from within a web context.  Some thing so basic as the code below could fail:using (SPSite site = new SPSite(“http://moss”)) { using (SPWeb web = site.OpenWeb()) { SPList list = web.Lists[“List1”]; list.Title = “List2”; list.Update(); web.Update(); } } Setting the “AllowUnsafeUpdates”…

6

Database Schema compatibility error in FBA

This is an interesting issue I came across recently and it was nice to know things that I thought would be hardly a matter to be considered. Well, the gist of the issue is very simple.  When using default providers (AspNetSqlMembershipProvider & AspNetSqlRoleProvider) to try to setup FBA, at the point of user and role…

1

Programming navigation in WSS 3.0

Modifying navigation elements through code is quite tricky in WSS 3.0.  Here are few scenarios, I’ve tried to cover that I think will be helpful in playing around with WSS 3.0 navigation elements.  I’ve used the top navigation bar in these examples.  But the same code should work for quick launch as well.   BTW:…

8

Add/Update "sealed" properties in SharePoint lists

There’s always a question about updating properties in a list in SharePoint.  Specifically, properties like “Modified By”, “Modified” etc.,  WSS 3.0 provides greater flexibility for enabling developers to do this with ease.  Usually, this scenario would be required when users with “Read” rights need to be able to perform certain updates to a list and…

1

GetWebTemplate web method does not return & AddList web method does not recognize my custom list templates!

When you use the “GetWebTemplate” web method provided through webs.asmx web service, you’ll notice that the custom list templates you might have created is not available in the collection returned.  This is because the OM call that happens behind-the-wires, calls the SPWeb.ListTemplates collection object.  This object does not return the custom list templates (simply called…

2

"Out of Memory" exception – when adding item to a list using SharePoint OM

Here’s the scenario: A tool that’s designed to add log messages from an application to a SharePoint list.  The log messages are themselves “strings”, which when put in a text file may vary anywhere between 1kb to 10mb in size.  At a single time, this logging process can run for anywhere between 20-30 minutes.  And…


Starting note on Content Editor Web Part

Recently, I worked a tricky and interesting case where a customer wanted to “silently” put a file in user’s computer.  My buddy, Sowmyan bet me by blogging about it here.  A job superbly done!!  Watch out for enabling Initialize and script ActiveX controls not marked as safe as that could potentially be harmful and lethal…