I have a jQuery .Change event for a DropDownList that works fine when a user changes the value, however, it doesn't work when the value is set in the code behind. Is there a way I can trigger jQuery .Change event from the code behind?
The client isn't aware of changes you make on the server. What you might do is use RegisterStartupScript to register a call to the code you want to trigger client-side. Or do something in document.ready. It really depends on what and how you're doing things.
Why you wnat to do such complecated way? You can simply do like this- Put all the code in the change event inside a function and call this function from change event. And also from the place where you are assigning the value of the dropdown like the following
post-
DaNuGai
Member
149 Points
87 Posts
DropDownList SelectedValue jQuery
Dec 18, 2012 11:52 PM|LINK
Hi,
I have a jQuery .Change event for a DropDownList that works fine when a user changes the value, however, it doesn't work when the value is set in the code behind. Is there a way I can trigger jQuery .Change event from the code behind?
Any other suggestions perhaps?
Thanks in advance
MetalAsp.Net
All-Star
112032 Points
18231 Posts
Moderator
Re: DropDownList SelectedValue jQuery
Dec 19, 2012 04:20 AM|LINK
asteranup
All-Star
30184 Points
4906 Posts
Re: DropDownList SelectedValue jQuery
Dec 19, 2012 04:25 AM|LINK
Hi,
Why you wnat to do such complecated way? You can simply do like this- Put all the code in the change event inside a function and call this function from change event. And also from the place where you are assigning the value of the dropdown like the following post-
http://forums.asp.net/t/1114513.aspx
If you wnat to do this explicitely with jquery then you can use __doPostBack with RegisterStartupScript-
http://www.delicious.com/anupdg/__doPostBack
http://www.delicious.com/anupdg/registerstartupscript
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog