ASP.Net VB Web Parts - Connections work fine, until I close, then reopen a web part.
am 03.05.2007 07:34:20 von itfetishI'm just starting out with ASP.net, making a web parts intranet.
I'm triyng to get some basic web parts (ascx files) working on a page,
I want them to share a variable, 'StaffID' which one part generates by
looking up the windows login name of the person viewing the page, and
then queries the database to find out the StaffID associated with that
name.
That part then shares it with all the other parts, using a class
called "IMessage", I have set up static connections for each
individual part,
The main part, Jobs_Main.ascx has this code:
Public ReadOnly Property Message() As String _
Implements IMessage.Message
Get
Return StaffID
End Get
End Property
Public Function GetMessage() As IMessage
Return Me
End Function
to assign the StaffID (which is generated on Page_Load - I also tried
Page_Init and this made no difference)
and then the other parts use
Public _message As IMessage
Sub SetMessage(ByVal message As IMessage)
Me._message = message
End Sub
in the scripts and then:
If (Not (_message) Is Nothing) Then
StaffID = "" & _message.Message & ""
Else
StaffID = 1
End If
That all works beautifully. If I change the staffID manually on
Jobs_main(in the code) all the others update next refresh. However I
have put in a catalog, and when I close a web part (the part I was
trying was FavouriteLinks.ascx) then add it again, it defaults to the
StaffID of 1...
So I assume it is not getting the _message value, or it thinks the
_message value is 0 for some reason? Does anyone know why this would
be? Could it be that it is loading before the jobs_main web part? If
so how do I make it load afterwards?