OnCheckChanged triggered multiple times for CheckBox in repeater in updatepanel
I've got a repeater in an update panel. the contents of the repeater is refreshed every 5 secs. (AsyncPostBackTrigger bound to the tick event of a timer)
In every item of the repeater there's a checkbox with autopostback set to true. I want the state of each checkbox to be preserved after each refresh of the repeater, that's why I save it's state in Page.Session. And then in the tick event handler I set the Checked value of the Checkbox to the value from the session. Unfortunately, this seems to trigger the OnCheckedChanged event and thus I do not k开发者_StackOverflow社区now anymore which event handler invocation comes from user interaction and which from code.
Anybody knows why the OnCheckChanged is triggered more than once and how can I prevent the extra occurencies? Is there a way to prevent the AsyncPostBackTrigger from triggering the OnCheckedChanged event of the Checkbox?
You can find out which control caused the post back by checking Page.Request.Params.Get("__EVENTTARGET")
, which returns the ID of the control. However...
I won't know for sure without reading your code, but you shouldn't need to worry about tracking which checkboxes are checked, the checked state should be saved in viewstate (unless you have it turned off...) So if this isn't the case there is probably something else wrong with your page.
精彩评论