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?

Était-ce utile?

La 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."

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top