pls HELP: webpart acting as shared but should be user

A

arthernan

I have an almost finished page that uses webparts. And this is the
expected functionality. A logged on user hits a button and the button
opens a WebPart. Then the user logs off, next time he logs on he will
find the webpart already open. Now, if a different user logs on, the
fact that another user might have opened a webpart should not affect
the page. For him the page should only show webparts that were open
inside his session.
This is not what is happening right now. Currently, if a user opens a
webpart, and then a different user logs on, the newly logged user will
have whatever webparts that he might have opened in the past plus the
ones opened by other user. Almost like the webpage was being modified
by everybody.

I am creating the WebParts dynamically from user controls using the
LoadControl command; then I use the WebPartManager.CreateWebPart and
last WebPartManager.AddebPart.

I have looked at my config file and the code and everything looks fine.
When I steep through the code after the webpart has been created I can
see this variables.
WebPartManager1.Personalization.HasPersonalizationState equals True
WebPartManager1.Personalization.Scope is user
WebPartManager1.Personalization.Enabled equals True

Does anybody know what I am doing wrong? Do I need to save the state?


Arturo Hernandez
 
G

Guest

Hey Atherton,
Please post some code for the group to help you or try using the
declaritiviecatalog part.

Good Luck
DWS
 
A

arthernan

OK, here goes nothing:

Private Function GetWebPart(ByRef WebPartType As ChuyWebPart) As
WebPart
Dim _WebPart As WebPart
For Each _WebPart In WebPartManager1.WebParts
If _WebPart.Title = WebPartType.DisplayName Then
Return _WebPart
End If
Next
Return Nothing
End Function

Private Function OpenWebPart(ByRef WebPartType As ChuyWebPart,
ByRef pWebPartZone As WebPartZone, ByVal ZoneIndex As Integer) As
WebPart
Dim _GenericWebPart As GenericWebPart
_GenericWebPart = GetWebPart(WebPartType)
If _GenericWebPart Is Nothing Then
Dim _UserControl As UserControl = LoadControl("~\Controls\"
+ WebPartType.ControlName + ".ascx")
_UserControl.ID = WebPartType.ControlName
_GenericWebPart =
WebPartManager1.CreateWebPart(_UserControl)
_GenericWebPart.Title = WebPartType.DisplayName
End If
If Not _WebPartManager1.WebParts.Contains(_GenericWebPart) Then
_GenericWebPart =
WebPartManager1.AddWebPart(_GenericWebPart, pWebPartZone, ZoneIndex)
End If

Return _GenericWebPart
End Function

There is something I probably need to clarify about my code. I was not
able to make a reference to the user control by type. So as a
workaround the only way I found to get a reference to a WebPart was to
use it's title. I will probably end up undoing this workapound whenever
I find a better way to do that.

Anyway any help will be greately appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,592
Members
45,104
Latest member
LesliVqm09
Top