Question

I have implemented a webpart with custom properties in an editor part. If I click apply or ok, the values are successfully updated (code in OnPreRender). The problem is now that if I click apply and then cancel, the changed values are saved and not discarded. I could not find a reason for that. Does anybody know a solution?

Was it helpful?

Solution

This is by design and not an error.

  1. Toolpart renders
  2. You update some properties in browser (A)
  3. You click apply and postback data
  4. ApplyChanges event saves data
  5. Toolpart renders with new data
  6. You (perhaps) update some values (B)
  7. You click Cancel
  8. Postback but does not update properties (ApplyChanges not fired)

Last data saved was (A) and thats what you've got - it cancelled any updates directly (B) before cancel.

Sure you could change this in your toolpart with some complex scheme but then your toolpart will work differently than everything else in SharePoint so is likely to be even more confusing.

Is this a real problem for you?

OTHER TIPS

Yea, i don't think onprerender is the right event to do this. It should be the applychanges override in the editorpart.

    public override bool ApplyChanges()
    {
        // Apply property values here.
        UserWebPart wp1 = (UserWebPart)this.WebPartToEdit;
        try
        {
            wp1.UserID = _p.CommaSeparatedAccounts;
            return true;
        }
        catch
        {
            return false;
        }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top