469,270 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

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.
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.  
  4.             NAVPointScriptServiceHandler.Basics.sendMessageToThePage += new NAVPointScriptServiceHandler.SendMessageToThePageHandler(Basics_sendMessageToThePage);
  5.        }
  6.  
  7. void Basics_sendMessageToThePage(string messageToThePage)
  8.         {
  9.               lblUserControlTextBoxValue.Text = messageToThePage;
  10.         }
  11.  
Here I do get the messageToThePage 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.
Aug 7 '08 #1
9 1478
acoder
16,027 Expert Mod 8TB
Show the HTML code for the label.

PS. please enclose your code in code tags. See How to Ask a Question. Thanks.
Aug 7 '08 #2
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.

Expand|Select|Wrap|Line Numbers
  1. 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.
Aug 7 '08 #3
acoder
16,027 Expert Mod 8TB
Show the client-side generated code, not ASP.NET, i.e. how it appears in your browser if you view the source.
Aug 7 '08 #4
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 heres 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 im asking you guys for some ideas as how to do this.
Anything would be helpful.

Thanks for the response:)

Regards, Viktor Einarsson.
Aug 7 '08 #5
acoder
16,027 Expert Mod 8TB
Call a function on the event in Table1 which makes the required changes to Table2 and Table3.
Aug 8 '08 #6
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.

Im sorry if this is confusing.
Thanks for the help, so far:)
Aug 8 '08 #7
acoder
16,027 Expert Mod 8TB
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.
Aug 8 '08 #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.
Ok I see.
Thanks for all the help:)
Aug 11 '08 #9
acoder
16,027 Expert Mod 8TB
No problem, you're welcome.

Just out of interest, what did you choose to do in the end?
Aug 11 '08 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.