javascript user control event for page.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viktore
    New Member
    • Jul 2008
    • 5

    javascript user control event for page.

    Hey guys, bad title i know:)

    Well my problem is as follows:

    I have a javascript user control, a grid, wich is on an .aspx page.
    On the grid I can scroll between records, up and down, and click them.
    Now I want to create an event in the grid that lets the page know if a different record is chosen, a record is changed and so on.

    I tried using event/delegates to solve this and I do get the information from the javascript to the page but when I try to change a label on the page, the label stays the same, with the original text value.

    The Page_Load for .aspx page.
    Code:
    protected void Page_Load(object sender, EventArgs e)
            {
    
                NAVPointScriptServiceHandler.Basics.sendMessageToThePage += new NAVPointScriptServiceHandler.SendMessageToThePageHandler(Basics_sendMessageToThePage);
           }
    
    void Basics_sendMessageToThePage(string messageToThePage)
            {
                  lblUserControlTextBoxValue.Text = messageToThePage;
            }
    Here I do get the messageToThePag e value, and when debugging i can see the value i sent from the javascript but the label does not change.
    Can anyone help me explain why or point me to a better way of doing this, preferably without using UpdatePanel? :)

    Thanks.
    Last edited by acoder; Aug 7 '08, 11:59 AM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Show the HTML code for the label.

    PS. please enclose your code in code tags. See How to Ask a Question. Thanks.

    Comment

    • viktore
      New Member
      • Jul 2008
      • 5

      #3
      Originally posted by acoder
      Show the HTML code for the label.

      PS. please enclose your code in code tags. See How to Ask a Question. Thanks.
      This is how im using my label on the page.

      Code:
      Value of user control TextBox is: <asp:Label ID="lblUserControlTextBoxValue" runat="Server"  Font-Bold="True" />
      But, better, i have a picture explaining what i want the user controls to be able to do.



      I want other instances of that user control to be able to listen to any of the user controls and maybe the page, but thats optional right now.

      The user controls use ajax enabled callbacks.

      Thanks for the reply.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Show the client-side generated code, not ASP.NET, i.e. how it appears in your browser if you view the source.

        Comment

        • viktore
          New Member
          • Jul 2008
          • 5

          #5
          Originally posted by acoder
          Show the client-side generated code, not ASP.NET, i.e. how it appears in your browser if you view the source.
          Ah ok, well since it wasnt working i removed from the javascript in my user control:)

          But here´s how it did work.

          1. When user pressed U in the user control called Table1.
          2. Table1 sends out an event.
          3. And every other user control(ex. Table2 and Table3) that is listening to that event should receive info from Table1.

          So basically i´m asking you guys for some ideas as how to do this.
          Anything would be helpful.

          Thanks for the response:)

          Regards, Viktor Einarsson.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Call a function on the event in Table1 which makes the required changes to Table2 and Table3.

            Comment

            • viktore
              New Member
              • Jul 2008
              • 5

              #7
              Originally posted by acoder
              Call a function on the event in Table1 which makes the required changes to Table2 and Table3.
              Thats an easy solution yes, but I am looking to call an event in Table1 and then, dynamically, any other object can listen and grab it.

              So all Table2 and Table3 would have to do, is to listen to Table1. "Assign" themselves to it.

              I´m sorry if this is confusing.
              Thanks for the help, so far:)

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                What you're looking for is Mutation Events. Unfortunately, support for it is currently poor in all browsers. In the meantime, either go for the easy alternative above or poll the DOM using setInterval.

                Comment

                • viktore
                  New Member
                  • Jul 2008
                  • 5

                  #9
                  Originally posted by acoder
                  What you're looking for is Mutation Events. Unfortunately, support for it is currently poor in all browsers. In the meantime, either go for the easy alternative above or poll the DOM using setInterval.
                  Ok I see.
                  Thanks for all the help:)

                  Comment

                  • acoder
                    Recognized Expert MVP
                    • Nov 2006
                    • 16032

                    #10
                    No problem, you're welcome.

                    Just out of interest, what did you choose to do in the end?

                    Comment

                    Working...