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 :)
If you don't want to validate form on first dropdown's selectionIndexChange, simple add property
CauseValidation="false"
and it will not fire form validation on selectionIndexChange.If you are adding controls dynamically (at run time) make sure you are not doing it in the
if(!IsPostBack)
block because you have to add controls even on the postback as well. This depends on how you add controls but generally these are common errors while dealing with such kind of problem
精彩评论