Dynamically added UserControl not firing PostBack event on selection change?

i have a very strange issue with a user control we are dynamically loading on an asp.net web page(.net 2.0). the user control has 3 dropdowns, one of which has a selectedindexchanged event attached to it (which loads the third dropdown with a set of values).

the weird thing is, if there are currently any invalid fields (where field validators have been activated) in other parts of the form, when you go to select the drop down in question on the FIRST change it does nothing, but then when you change the index again it works perfectly! i dont understand how the event wont fire for the first change, but for every change thereafter.

However, if all these fields are filled in correctly above the usercontrol, it fires off the selectedindexchanged event correctly.

in regards to validation i have disabled ALL POSSIBLE validation in order to try and eliminate it as a culprit, so i dont understand how validation can be affecting the usercontrol.

any help would be greatly appreciated :)

1
задан Adam G 6 April 2012 в 01:07
поделиться

1 ответ

  1. Если вы не хотите проверять форму при выборе selectionIndexChange в первом раскрывающемся списке, просто добавьте свойство CauseValidation = "false" , и оно не будет запускать проверку формы при selectionIndexChange.

  2. Если вы добавляете элементы управления динамически (во время выполнения), убедитесь, что вы не делаете этого в блоке if (! IsPostBack) , потому что вам нужно добавить элементы управления даже при обратной передаче.Это зависит от того, как вы добавляете элементы управления, но обычно это распространенные ошибки при решении такого рода проблем

2
ответ дан 2 September 2019 в 21:58
поделиться
Другие вопросы по тегам:

Похожие вопросы: