On my NewForm.aspx
or EditForm.aspx
pages I am using jQuery to fill in a peoplepicker control.
The problem is that this causes the page to POST this error:
"This Page has been modified since you opened it. You must open the page again."
This error, in the ULS is System.Web.UI.ViewStateException: Invalid viewstate
.
This page has a few suggestions to solve this, but I haven't figured out just what to do yet. Also, I have a thread in the spservices Discussions over on CodePlex, but I need an answer. And there is this thread, but it's tagged C#
and doesn't help me with a jQuery issue.
Here is the code I'm using to fill in the peoplepicker control:
SetPeoplePickerToCurrentUser("Requestor",false);
function SetPeoplePickerToCurrentUser(whatDisplayName, overwrite){
//var currentControlValue = $().SPServices.SPFindPeoplePicker({ peoplePickerDisplayName: whatDisplayName }).row.find("span[class='ms-entity-resolved']").attr("title");
var currentControlValue = $("div[title='People Picker']").text().trim();
if(overwrite || currentControlValue == undefined || currentControlValue == ""){
var currentuser = $().SPServices.SPGetCurrentUser({ fieldName: "Name", debug: false });
var peoplepicker = $("div[title='People Picker']");
peoplepicker.text(currentuser);
$('a[title="Check Names"]').click();
}
}
[update]
Well, I've discovered that this actually does work, but if the user refreshes the page without saving, THEN it locks up with the viewstate error. Normally, a person can refresh without saving. The function won't modify the value again if there is anything in it. Normally, if a person refreshes a page without saving, a people-picker control gets blanked out, but the custom form's people-picker does not get emptied out.