Trouble moving web parts from one zone to another.

Last post 10-25-2005 9:43 AM by timiscool999. 2 replies.

Sort Posts:

  • Trouble moving web parts from one zone to another.

    10-21-2005, 12:26 PM
    • Member
      22 point Member
    • timiscool999
    • Member since 01-14-2003, 4:50 PM
    • Chicago, IL
    • Posts 6
    Hi.  I'm sorry to post such a vague question, but I hope someone can at least tell me where to start looking to narrow down the problem I'm having.

    I have code that moves a web part on a post back.  It used to work before so I'm not sure where the regression is (or if something changed in the .NET framework with the RC0 release), but I'm getting the following stack trace when I call WebPartManager.MoveWebPart():

    [InvalidOperationException: Personalization is not enabled and/or modifiable. The Enabled property must be set to true, and a registered personalization provider must be selected. The current user must be granted the right to modify personalization state.]
    System.Web.UI.WebControls.WebParts.WebPartPersonalization.EnsureEnabled(Boolean ensureModifiable) +145
    System.Web.UI.WebControls.WebParts.WebPartManager.MoveWebPart(WebPart webPart, WebPartZoneBase zone, Int32 zoneIndex) +46
    edu.depaul.cti.col.COLCoreWebControls.WebParts.COLWebPartZone.MinimizeWebPart(WebPart webPart) in C:\devroot\colweb2\ColWeb2\COLCoreWebControls\WebParts\COLWebPartZone.cs:103
    edu.depaul.cti.col.COLCoreWebControls.WebParts.COLWebPartZone.RaisePostBackEvent(String eventArgument) in C:\devroot\colweb2\ColWeb2\COLCoreWebControls\WebParts\COLWebPartZone.cs:283
    System.Web.UI.WebControls.WebParts.WebPartZoneBase.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +172
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921


    Version Information: Microsoft .NET Framework Version:2.0.50727.26; ASP.NET Version:2.0.50727.26



    I've tried manually connecting to the personalization database with an SqlConnection object using the query string that the Personalization provider is using, and I can insert records into that database with an SqlCommand object.  This would indicate to me that there aren't any problems actually connecting to the database.

    When I look at the WebPartManager.Provider object in the debugger, it's set to "Shared" scope.  Now in my code I set the WebPartManager.InitialScope to "User", but somewhere it gets changed.  I don't have any code in my project where I set it to "Shared", so how would it be reverting back to "Shared"?

    What else can I look for to see where this is going wrong?  What else could I be forgetting that I need to enable for web parts personalization to work?

    Thanks for any help!

  • Re: Trouble moving web parts from one zone to another.

    10-24-2005, 8:04 PM
    • Member
      115 point Member
    • helenyan
    • Member since 07-06-2004, 5:50 PM
    • Posts 23
    Is it possible that the current user is not authenticated? Are you using Forms or Windows auth? Can you check the values of Page.User.Identity.IsAuthenticated and Page.User.Identity.Name? When the current user is not authenticated, the Personalization scope will be defaulted to "Shared" and the current user does not have the permission to modify personalization state.

    Hope that helps.
    Helen
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Trouble moving web parts from one zone to another.

    10-25-2005, 9:43 AM
    • Member
      22 point Member
    • timiscool999
    • Member since 01-14-2003, 4:50 PM
    • Chicago, IL
    • Posts 6
    Ahh very tricky :).  Found a subtle bug in my code.  But yes, thank you Helen, that did the trick!

    Tim

Page 1 of 1 (3 items)