ASP.Net VB Web Parts - Connections work fine, until I close, then reopen a web part.

I

itfetish

Accidentally put this in normal ASP newsgroup, so reposting:

I'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

<ConnectionProvider("Message", AllowsMultipleConnections:=True)> _
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

<ConnectionConsumer("Message")> _
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?
 
I

itfetish

anyone who cares, I instead dessided to go with a 'master page' and
use a Session("StaffID") variable
 

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,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top