I'm trying to add a button on a page that remove any personalization.
I use this code :
protected void MyButton_Click(object sender, EventArgs e) {
WebPartManager.Personalization.ResetPersonalizationState();
// other cleanup methods
}
However, this code is failling with this error:
The 'ResetPersonalizationState' method of 'WebPartPersonalization' cannot be called before initialization of the page is complete
What is the correct way to implement this behavior?
[Edit] Please note that I'm working on server side. Actually, I'm performing some other cleanup when clearing the personalizations.
I try to perform a postback after calling the MSOWebPartPage_RestorePageDefault
but it seems that this method itself is performing a post, so my postback is ignored.
I used this code:
javascript:SP.SOD.executeFunc('browserScript', 'MSOWebPartPage_RestorePageDefault', function(){
MSOWebPartPage_RestorePageDefault();
__dopostback(...); // actually generated on the server side
})
But as I said, it does not works (the __dopostback is ignored as the MSOWebPartPage_RestorePageDefault itselft postback.