Turns out that adding the Format attribute to the CalendarExtender only solved the problem for one set of load events. I had a separate textbox-CalendarExtender pair, and when that changed, I automatically propagated the value to every textbox-calendarExtender pair in the grid; when that DataBind occurred, the same error resurfaced. I was unable to reproduce in a bare-bones project, but I found I'm not the only one to experience the problem--see this:
http://forums.asp.net/t/1679414.aspx[
^]
Some observations:
1) removing the CalendarExtender prevents the error, but removes functionality
2) adding an alert in the onchange before it posts back to the server for some reason clears up the issue of the unwanted postbacks being disconnected from the main thread, but they still occur
3) the poster in the link above claims a different format (yyyy/MM/dd) also helps--I did not try this
What I finally did was to follow the link above, reworking my functionality so that instead of existing in the Textbox's onchange event, it exists in the CalendarExtender's OnClientDateSelectionChanged. Many annoying little refactors later, it runs without error.
Markup:
<itemtemplate>
<asp:textbox width="92%" id="txtSubCompleteDt" runat="server" xmlns:asp="#unknown"></asp:textbox>
<asp:calendarextender id="dtpSubtaskComplete" runat="server" targetcontrolid="txtSubCompleteDt" format="MM/dd/yyyy" onclientdateselectionchanged="dateSelectionChanged" xmlns:asp="#unknown"></asp:calendarextender>
</itemtemplate>
and script:
function dateSelectionChanged(sender) {
var selectedDate = sender.get_selectedDate().localeFormat(sender.get_format());
if (!validateDateString2(selectedDate)) {
return false;
}
else {
onkeyupEnable();
ajaxPostbackTrigger('gridchg:' + (sender._element.parentElement.parentElement.rowIndex - 1) + ':3:' + selectedDate);
}
}
Code behind:
Dim txtControl As TextBox = e.Row.Cells(GridCols.SubtaskCompleteDt).Controls(1)
txtControl.Attributes.Add("onblur", "if (!validateDateString(this)) {this.value = ''; this.focus();}")