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

Discussion in 'ASP .Net' started by itfetish@gmail.com, May 3, 2007.

  1. Guest

    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?
    , May 3, 2007
    #1
    1. Advertising

  2. Guest

    anyone who cares, I instead dessided to go with a 'master page' and
    use a Session("StaffID") variable
    , May 15, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    581
    Keith Thompson
    Mar 31, 2007
  2. niama
    Replies:
    2
    Views:
    119
    niama
    Mar 9, 2005
  3. Replies:
    0
    Views:
    256
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    815
    Iñaki Baz Castillo
    Jan 12, 2010
  5. tshad
    Replies:
    13
    Views:
    225
    tshad
    Mar 25, 2005
Loading...

Share This Page