Question

Server Error when updating a field:

The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.

var creatdbyfield = spList.Fields["Created By"];
creatdbyfield.ReadOnlyField = false;
creatdbyfield.Update();

Crashing on the Update() call. Has anyone seen this before?

Was it helpful?

Solution

Use below code :

web.AllowUnsafeUpdates = true;  //here web is the spweb object
var creatdbyfield = spList.Fields["Created By"];
creatdbyfield.ReadOnlyField = false;
creatdbyfield.Update();
web.AllowUnsafeUpdates = false;

Reference - Exception : "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again."

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top