I have a usercontrol inside a repeater, which has some custom validation. I create a validation group for each textbox-button pair in OnItemDataBound. In the local environment, the validation is working for each control individually. In our staging environment, clicking one button validates all the textboxes.
Looking at the generated JS code, I see a difference. I don’t know if this is significant, but it might be.
Staging:
cphBody_bodyContent_rptFieldsSummary_ucFieldSummary_0_ucNewSubjectQuestion_0_vldNotHintText_0.clientvalidationfunction = "HintText_ClientValidate";
Local:
ctl00_ctl00_cphBody_bodyContent_rptFieldsSummary_ctl00_ucFieldSummary_ucNewSubjectQuestion_vldNotHintText.clientvalidationfunction = "HintText_ClientValidate";
Could this be the issue? In any case, if someone knows why this difference exists, I would love to know, even if it’s not the solution to my issue 🙂
This could become an issue if you have any other code that refers to these elements by ID. Obviously with the lines you provided, the Event Handlers are still going to be properly assigned.
If you’re worried about this becoming an issue, set all of the controls’ “ClientIDMode” to “Static”, and then assign them an ID. This should cause the Textboxes/Buttons to always have the same IDs.
Note this only occurs with ASP .NET controls, not standard HTML ones.