views:

194

answers:

2

Hi all;

<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...

+2  A: 

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 on javascript.

<script type="text/javascript"> 
    $(function() {
        $(".clDate").datepicker();
    });
</script> 

Also for the update panel to fix again the DatePicker after the ajax update you need the foloowing code

<script type="text/javascript"> 
var prm = Sys.WebForms.PageRequestManager.getInstance();    
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args) {      
}

function EndRequest(sender, args) {
     $(".clDate").datepicker();
}
</script> 

Update:About the Sys. -> http://msdn.microsoft.com/en-us/library/bb311028.aspx

Aristos
+1 it must as per me
Pranay Rana
@Aristos Error: Microsoft JScript runtime error: 'Sys' is undefined pls help me
Oraclee
@oraclee do you have place the ScriptManager ? (because of your update panel you need to have it)
Aristos
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"> </asp:ScriptManager> not work Microsoft JScript runtime error: 'Sys' is undefined
Oraclee
@oraclee you need to place the Sys. after the scriptManager !!!, or make it load when page load. See the example here : http://msdn.microsoft.com/en-us/library/bb311028.aspx
Aristos
@Aristos ok thank you, i code work
Oraclee
@oraclee Ok cool :)
Aristos