Teun.ToString()

by Teun Duynstee [Macaw]

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Subscriptions

News

I discontinued this blog. I now post at: www.TeunToString.net



Download Finch PocketBlogger

Post Categories

Article Categories



Tuesday, March 15, 2005 - Posts

Reading and changing the Web Part Configuration

In ASP.NET 2.0, the Portal Framework allows users to personalize their page to their liking. The configuration they choose is stored as a BLOB that only the WebPartManager can make sense of. What's more: the WebPartManager only works in the context of the user visiting the page. You cannot use the WebPartManager to change the configuration of other users, nor to read or change the configuration of other pages.

I have created a library that allows you to take the binary info that the WebPartManager stores in the personalization system and read it's content through collections and properties. You can even make changes and add or remove entries and then serialize this information back to the format that the WebPartManager understands.
You could use this functionality to make tools that update certain personalized information for all users in your system. Or to remove any instances of a web part that you offered to the users before, but you don't want to anymore. In that case, you have to programmatically change the personalization blob for all users that added the web part to their page.

The way to work with the library is like this:

The PageSettings class exposes 3 collections of properties. Each holds specific information on a number of controls, but not necessarily the same controls.

DynamicParts These are the controls that must be added to the page dynamically. They are not coded into the ASPX, but are added to the page from a catalog.
Locations This contains information on the location of web parts. Each entry contains a ZoneID, ZoneIndex. It also contains an IsClosed property that indicates whether the part is visible on the page.
WebPartSettings The collection contains all of the other properties that can be set on a web part. Normally, these are the public properties of the web part that are marked WebBrowsable with an attribute.

I haven't had the time for proper testing and documentation, but maybe this is already of use to someone out there. If you make any changes that could benefit others as well, please let me know.

The library and sources can be downloaded here.

posted Tuesday, March 15, 2005 3:39 PM by TeunD with 495 Comments




Powered by Dot Net Junkies, by Telligent Systems