How to access asp_personalizationPerUser ?

Rate It (2)

Last post 06-03-2006 3:25 PM by pkellner. 11 replies.

Sort Posts:

  • How to access asp_personalizationPerUser ?

    04-27-2006, 11:13 AM
    • Member
      85 point Member
    • ilegare76
    • Member since 10-17-2005, 2:55 AM
    • Quebec, Canada
    • Posts 17

    Hello,

    I work on a project where people can add personnalized content to their "MyPage".  I don't use the catalogPart and I programmatically add the webpart controls to the page.

    My own catalog is organized by roles so the user can only add webpart related to his roles (user can have multiple roles).

    My problem is : on the user login, I synchronize roles with an external database.  If a user loses one role, how can I remove webparts related to this role on his "MyPage".  I need to know all webparts on his "MyPage" and remove (programmatically) theses webparts...

    So :
    1 - how to know all user webParts (read aspnet_personalizationPerUser)
    2 - how to remove programmatically a webpart identified previously by the table aspnet_personalizationPerUser)

    Thanks you very much, I'm very desperate ;-)

    Iannick
    P.S. Sorry for my "medium" english !

  • Re: How to access asp_personalizationPerUser ?

    05-01-2006, 4:10 PM
    • Member
      85 point Member
    • ilegare76
    • Member since 10-17-2005, 2:55 AM
    • Quebec, Canada
    • Posts 17

    Hi, still me..
    First of all, here how to transform a user control to webpart and add it dynamically to the user "MY" Page.

    Dim
    controlRSS As Control = Page.LoadControl("webParts\rss.ascx")
    controlRSS.ID =
    "id1"

    Dim
     wpRSS As GenericWebPart = wpManager.CreateWebPart(x)
    wpRSS.ID ="rssID"
    wpRSS.Title = "CNN News"
    wpManager.AddWebPart(wpRSS, wpZone1, 1)
    _______________________________________
    Now, to access to all the user webparts:
    For Each wp As GenericWebPart In wpManager.WebParts
       if wp.ID = "rssID" then do something --DON'T WORK
    Next

    My problem : I need to check if the user have the wpRss webpart in his webparts collection but I can't set the ID of the webPart before to add it...

    Someone have an idea ?  M. Harder?

    Thanks,
    Iannick

     




     

  • Re: How to access asp_personalizationPerUser ?

    05-01-2006, 4:34 PM
    • Member
      110 point Member
    • kovalov
    • Member since 02-24-2006, 7:53 PM
    • Posts 22

    Have exactly the same problem. The ID field gets reassigned by the framework to a random number (something like "wp580609608"). Any ideas how to solve the problem?

     

    And another question. Is there any way to access User specific data (declared as Personalizable property inside an "ascx" webcontrol) for a dynamically created web part?

     

  • Re: How to access asp_personalizationPerUser ?

    05-01-2006, 4:59 PM
    • Member
      85 point Member
    • ilegare76
    • Member since 10-17-2005, 2:55 AM
    • Quebec, Canada
    • Posts 17

    >>And another question. Is there any way to access User specific data (declared as >>Personalizable property inside an "ascx" webcontrol) for a dynamically created web part?

    I think you must use the profile
    Take a look on this post:
    http://forums.asp.net/thread/1269001.aspx

  • Re: How to access asp_personalizationPerUser ?

    05-02-2006, 11:04 AM
    • Member
      110 point Member
    • kovalov
    • Member since 02-24-2006, 7:53 PM
    • Posts 22

    Probably not the best solution, but very simple:


    Dim controlRSS As Control = Page.LoadControl("webParts\rss.ascx")
    controlRSS.ID =
    "id1"

    Dim
     wpRSS As GenericWebPart = wpManager.CreateWebPart(x)
    wpRSS.Description ="rssID"
    wpRSS.Title = "CNN News"
    wpManager.AddWebPart(wpRSS, wpZone1, 1)
    _______________________________________
    Now, to access to all the user webparts:
    For Each wp As GenericWebPart In wpManager.WebParts
       if wp.Description = "rssID" then do something

    Next

     

    Sertenly, Description field should be unique.

  • Re: How to access asp_personalizationPerUser ?

    05-02-2006, 2:54 PM
    • Member
      85 point Member
    • ilegare76
    • Member since 10-17-2005, 2:55 AM
    • Quebec, Canada
    • Posts 17

    Hello,
    In my situation (I have my own catalog), I think that's a good solution.  I haven't seen the description property, thanks.

    Description property:
    Gets or sets a brief phrase that summarizes what a control does, for use in ToolTips and catalogs of server controls.

    Thanks,

    Iannick
    P.S. If someone have a solution with the ID, send me an email !

  • Re: How to access asp_personalizationPerUser ?

    05-03-2006, 8:26 PM
    • Member
      85 point Member
    • ilegare76
    • Member since 10-17-2005, 2:55 AM
    • Quebec, Canada
    • Posts 17

    OK, my last comments about this post:

    From David Barkol
    You can only set the id of the control that you are loading but not on a
    webpart that you create dynamically.


    Iannick

  • Re: How to access asp_personalizationPerUser ?

    05-04-2006, 2:47 PM
    • Participant
      1,290 point Participant
    • vishal_7
    • Member since 05-15-2004, 12:40 PM
    • Posts 258

    HI,

      I am adding dynamic webparts as well. I extended the standard WebPartManager with my own so that I can call the SetPersonalizationDirty Function to save the webpart into the users personalization profile. The problem is now that when I reload a second window then it re-adds those webparts again - so 2 webparts becomes 4 then 4 becomes 8 etc....How can I get rid of that? I think I need to check if certain webparts are already added to the users personalization and if not then I need to add them. Is that the way it should work?

    Please advice.

    Thanks

  • Re: How to access asp_personalizationPerUser ?

    05-08-2006, 4:54 PM
    • Contributor
      4,557 point Contributor
    • mharder
    • Member since 11-22-2002, 7:03 AM
    • Redmond, WA
    • Posts 917
    • AspNetTeam
      Moderator
    Original question: You shouldn't work directly against the data in the database.  Have you tried using the WebPartManager.AuthorizeWebPart method?

    Saving arbitrary data on WebPart: You could use the AuthorizationFilter property.  This is a string property designed to hold data related to whether a WebPart is authorized for the page.  For instance, you could set this property to a list of allowed user roles.

    Adding dynamic WebParts multiple times: This has been covered many times before.  Search for terms like "static webpart", "dynamic webpart", and "SetPersonalizationDirty()".

    -Mike
    http://blogs.msdn.com/mharder

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: How to access asp_personalizationPerUser ?

    06-02-2006, 1:04 AM
    • All-Star
      23,823 point All-Star
    • pkellner
    • Member since 11-12-2004, 5:42 AM
    • San Jose, California
    • Posts 3,579
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi Mike,

    Just a quick follow up question.  Is there any way with the webpartsmanager to reset (or delete) the entry in the aspnet_PersonalizationPerUser for the current user?  I don't want to go directly against the database, but I don't see another way to do it.

    Thanks

    Peter Kellner
    http://peterkellner.net
    Microsoft MVP • ASPInsider
  • Re: How to access asp_personalizationPerUser ?

    06-02-2006, 3:07 PM
    • Member
      78 point Member
    • volant
    • Member since 05-22-2006, 8:34 PM
    • Posts 21
    pkellner:

    Hi Mike,

    Just a quick follow up question.  Is there any way with the webpartsmanager to reset (or delete) the entry in the aspnet_PersonalizationPerUser for the current user?  I don't want to go directly against the database, but I don't see another way to do it.

    Thanks

     
     WebPartManager _manager
            = WebPartManager.GetCurrentWebPartManager(Page);
            
        _manager.Personalization.ResetPersonalizationState();
     
  • Re: How to access asp_personalizationPerUser ?

    06-03-2006, 3:25 PM
    • All-Star
      23,823 point All-Star
    • pkellner
    • Member since 11-12-2004, 5:42 AM
    • San Jose, California
    • Posts 3,579
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs
    thanks.  worked perfect. 
    Peter Kellner
    http://peterkellner.net
    Microsoft MVP • ASPInsider
Page 1 of 1 (12 items)