Run JavaScript after a DropDownList is DataBound
Posted
by Daniel Coffman
on Stack Overflow
See other posts from Stack Overflow
or by Daniel Coffman
Published on 2010-04-14T19:39:31Z
Indexed on
2010/04/14
19:43 UTC
Read the original article
Hit count: 323
I need to trigger a JavaScript function to be called AFTER a DropDownList on my ASP.NET WebForms page is DataBound, because the SelectedIndex of this DropDownList is the parameter to the JavaScript function.
I've tried this various ways, but it seems that if I do it with pure JavaScript onload by using ClientScript.RegisterStartUpScript, the control can be found (because it hasn't been assigned a clientID yet?). If I use jQuery (document).ready { } it says that the DropDownList has no selectedIndex.value.
So I need some JavaScript to run AFTER the control has a value set by the DataBind.
How can I accomplish this? onChanged won't work because I need the function to fire on the first page load, with no user input. DataBinding the SelectedIndex of the DropDownList doesn't cause the JavaScript onChanged event to fire.
© Stack Overflow or respective owner