Getting jQuery datepicker to attach to a TextBox within a ListView
- by Clay
I am using the jQuery Datepicker without any problem for TextBox controls that are non-templated. However, I am unable to get the datepicker to work with a TextBox that is in an EditItemTemplate of a ListView control. My latest attempt is to get a handle on this textbox by CSS class name "DateControl", any ideas?
<asp:ListVIew id="lvTest" runat="server">
<LayoutTemplate>...</LayoutTemplate>
<ItemTemplate>...</ItemTemplate>
<EditItemTemplate>
<tr>
<td>
<asp:TextBox ID="txtExpReceiveDate" runat="server" Text='<%#Eval("exp_receive_date","{0:dd-MMM-yy}") %>' CssClass="DateControl" />
</td>
</tr>
</EditTemplate>
</asp:ListView>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('DateControl').datepick({ dateFormat: 'M-dd-yyyy' });
});
</script>