views:

13

answers:

1

Hello everyone,

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 :)

A: 

Hi,

  1. 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.
  2. If you are adding controls dynamically (at run time) make sure you are doing it in the blog without if(!IsPostBack) 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
lakhlaniprashant.blogspot.com