Problem with multiple datepickers with same ID

Problem with multiple datepickers with same ID

This is same as  https://forum.jquery.com/topic/problem-with-multiple-datepickers-with-same-id

I've the control using datepicker on one of the dialogs. This dialog uses Something.cshtml. On this page, there is a provision to add child which is of same type. So, the dialog on the parent dialog also uses the same cshtml, as a result of which the id for the input is same. Now, when I select a date on the child dialog, it actually sets date on the parent dialog.

I've tried things like specifying the form name in each dialog.. like

$("#frmChild .datepicker").datepicker({dateFormat: Globalize.getPatternForDatepicker()});

and

$("#frmChild input[id=StartDate]").datepicker({dateFormat: Globalize.getPatternForDatepicker()});

None of them worked for me. In either cases, it is setting date on the control on parent dialog. Since, the dialog are rendered from the same cshtml, I can not change the ids :(


HELP!