Wednesday, March 28, 2012

Calling javascript from a control

I think this is a newbie question but it has me stumped.

I want to call a javascript function on a control when an event is fired. Specifically I want to call a javascript function when the value of a label changes.

i.e.

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

When that changes, call the javascript function HelloWorld()

that label is getting updated through a slidercontrol, so I was thinking about using the "onunload" event, but I'm really not sure.

I don't think the label control has onchange event in javascript. You could implement an AJAX timer and check if the label was change every x amount of second.

Sample how to use the Ajax timer here:http://alpascual.com/blog/al/archive/2006/12/21/Code-Snip-_2200_AJAX-Timer_2200_.aspx

No comments:

Post a Comment