Hi,
I'm trying to update one of field in SharePoint list using code behind from InfoPath form. With below code, I'm getting The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. I tried additional code with commented out statements too, but same problem.
Is it possible to update SharePoint metadata from InfoPath code behind? I can upload/create new list and delete wihtout a problem, but update fails.
Thanks.
string tempStrUrl = http://server;
string listName = "LibName";
string fileName = "xyz.txt";
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPWeb site = new SPSite(tempStrUrl).OpenWeb())
{
//Microsoft.SharePoint.Administration.SPWebApplication webApp = site.Site.WebApplication;
//webApp.FormDigestSettings.Enabled =
false;site.AllowUnsafeUpdates = true;
tempLocation = tempStrUrl +
"/" + listName + "/" + fileName;
try
{
SPListItem item = site.GetListItem(tempLocation);if (null != item)
{
item["Status"] = "Finalize";
//item.SystemUpdate();
item.Update();
}
}
catch (Exception ex)
{
string v = ex.Message;
}
//webApp.FormDigestSettings.Enabled = true;site.AllowUnsafeUpdates = false;
}
});