Unable to Delete last WebPart off of Page

Last post 05-08-2008 4:45 AM by abroeders. 7 replies.

Sort Posts:

  • Unable to Delete last WebPart off of Page

    01-21-2008, 11:30 PM
    • Loading...
    • Horse_Fly
    • Joined on 04-19-2007, 3:04 PM
    • Posts 6

    I have an application that is allowing users to Add, Edit, and Delete WebParts (which are User Controls) from one page with two WebPartZones.  It seems to work except when there is only one WebPart left on the page and you try to Delete it.  It appears to delete in Edit mode (plus, WebPartManager.WebParts.Count=0) but then when you hit Finish and go back to Browse mode, the WebPart is still there.  Through debugging I was able to determine that SavePersonalizationBlob() from our PersonalizationProvider (inheriting SQLPersonalizationProvider) is not called after the Delete on the last WebPart like it is on the other deletes.  So as it returns to Browse mode, it loads the blob saved before the delete. This seems like a bug to me, or maybe I'm just misunderstanding how this works.

    I thought I could work around this by forcing a save on finish of editting, but it seems to be impossible.  I developed my own WebPartManager class and tried to use SetPersonalizationDirty() but I think that just sets a flag and doesn't actually fire the event to save.  If I exit the app and come back with this change, the WebPart is actually gone.  So that's something, but not an acceptable long term solution.  Without the SetPersonalizationDirty() call, the WebPart is still there when I open it up again.

    Any ideas?  I have been unable to find anyone else having this trouble.

  • Re: Unable to Delete last WebPart off of Page

    01-22-2008, 3:33 AM
    • Loading...
    • darsho
    • Joined on 08-26-2006, 11:38 AM
    • cairo
    • Posts 165

    may be you forgot one of the inherited method of the SQLPersonalizationProvider

    if you want the .cs file of the Microsoft SQLPersonalizationProvider you can find it there. then you can compare to see what you may forgot : http://weblogs.asp.net/scottgu/archive/2005/08/01/ASP.NET-2.0-Provider-Toolkit-now-available-for-Download.aspx

    Mark As Answer If my reply helped you.
  • Re: Unable to Delete last WebPart off of Page

    01-22-2008, 10:39 AM
    • Loading...
    • Horse_Fly
    • Joined on 04-19-2007, 3:04 PM
    • Posts 6

    I put all of the inherited methods in there and that didn't seem to fix it.

    When I debug, this is the route it takes on Delete of the 2nd to last module on the page: SavePersonalizationState -> SavePersonalizationBlob 

    Then for the last module, it does:  SavePersonalizationState->ResetPersonalizationBlob

    It's actually reseting the state for some reason.  I have no idea what code is in SavePersonalizationState but apparently it's making the decision to reset the state.

  • Re: Unable to Delete last WebPart off of Page

    01-22-2008, 10:57 AM
    • Loading...
    • darsho
    • Joined on 08-26-2006, 11:38 AM
    • cairo
    • Posts 165

    the code for SavePersonalizationState  is in the link i mentioned before you may check it because i made my custom provider and it is working well by writing the same code except changing the StoredProc names to suit mine and it is working well

    Mark As Answer If my reply helped you.
  • Re: Unable to Delete last WebPart off of Page

    01-22-2008, 11:50 AM
    • Loading...
    • Horse_Fly
    • Joined on 04-19-2007, 3:04 PM
    • Posts 6

    We don't really have a custom provider.  The only reason we overwrote it was to add one property.  For example, my SavePersonalizationState function just calls base.SavePersonalizationState (base being SqlPersonalizationProvider).  We are not doing any custom procedures and such.

    I really don't think that our class is the problem.  We're not controlling what calls Save, Reset, or Load.  The SqlPersonalizationProvider is making those decisions.  And it works for every single Delete, Add, or Edit except when there is only one WebPart left. 

    I was unable to find the code for SavePersonalizationState in that link.  I found examples of overriding it but not the original code.

  • Re: Unable to Delete last WebPart off of Page

    01-23-2008, 4:26 AM
    • Loading...
    • darsho
    • Joined on 08-26-2006, 11:38 AM
    • cairo
    • Posts 165

    are all your webparts added dynamically or you have static webparts?

    Mark As Answer If my reply helped you.
  • Re: Unable to Delete last WebPart off of Page

    01-23-2008, 3:52 PM
    • Loading...
    • Horse_Fly
    • Joined on 04-19-2007, 3:04 PM
    • Posts 6

    They are all added dynamically on that page.  The user gets a blank page to add and delete webparts as needed. 

  • Re: Unable to Delete last WebPart off of Page

    05-08-2008, 4:45 AM
    • Loading...
    • abroeders
    • Joined on 05-08-2008, 4:38 AM
    • Posts 1

    Is this problem solved already. I'm having the exact same behavior. It seems that the partmanager isn't using saveblobs if the webpartcount on the webpartzones is (or becomes) zero.

    I create webparts dynamically from a custom catalogpart. I can add any number of webparts (they are saved in the standard personalisationprovider), deleting them also works, except when the last webpart is deleted from the page, the zones look empty, but after reloading the page, the last deleted webpart appears again.

    This thing is driving me crazy, does anyone have a solution to this problem?

Page 1 of 1 (8 items)