<asp:UpdatePanel ID="asd" runat="server">
<ContentTemplate>
<asp:GridView ID="gvUpdate" runat="server">
<Columns>
<asp:TemplateField HeaderText="DATE">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%# Eval("DATE","{0:dd.MM.yyyy}")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtDate" runat="server" Text='<%# Eval("DATE","{0:dd.MM.yyyy}") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</ContentTemplate>
i want jquery datepicker for “txtDate” how to make ?
Thank you…
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The most simple way is to place a class on your Date Text box, and just use jQuery to add the datepicker…
<EditItemTemplate>
<asp:TextBox ID="txtDate" CssClass="clDate"
runat="server" Text='<%# Eval("DATE","{0:dd.MM.yyyy}") %>'></asp:TextBox>
</EditItemTemplate>
and the javascript for init this is: $(".clDate").datepicker(); but the update panel is need again initialization after the Update, so the final code will be:
<script type="text/javascript">
// if you use jQuery, you can load them when dom is read.
$(document).ready(function () {
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// Place here the first init of the DatePicker
$(".clDate").datepicker();
});
function InitializeRequest(sender, args) {
// make unbind to avoid memory leaks.
$(".clDate").unbind();
}
function EndRequest(sender, args) {
// after update occur on UpdatePanel re-init the DatePicker
$(".clDate").datepicker();
}
</script>
Update:About the Sys. -> http://msdn.microsoft.com/en-us/library/bb311028.aspx
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0