asp.net - Jquery datepicker write in other textbox -
i.ve problem jquery datepicker. here tehe code
<asp:gridview id="compincgridview1" runat="server" allowpaging="true" allowsorting="true" autogeneratecolumns="false" datakeynames="d_id" clientidmode="static" > <columns> <asp:templatefield headertext="data idoneità"> <edititemtemplate> </edititemtemplate> <itemtemplate> <asp:textbox cssclass="datepick" id="complydatetb1" runat="server" text='<%# bind("complydate", "{0:d}") %>'></asp:textbox> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> and jquery code
$(document).ready(function () { $(".datepick").datepicker($.datepicker.regional['it']); }); the problem when click on textbox, calendar appears when choose day, date written on first textbox of table.
thanks
first of i reproduce error here, base on jquery datepicker tutorial.
the issue come because on gridview text controls have same ids. 1 simple solution remove ids, , let asp.net add them automatically , issue go away see on final test: http://jsfiddle.net/b7egj/1/ , code working page:
<p>date: <input type="text" class="dp" /></p> <p>date: <input type="text" class="dp" /></p> <p>date: <input type="text" class="dp" /></p> <p>date: <input type="text" class="dp" /></p> <p>date: <input type="text" class="dp" /></p> <script> $(function() { $( ".dp" ).datepicker(); }); </script> normally ids on controls must unique, not sure if datepicker wrong or not keep id of control opens , add date, @ same time open base on handler. other side asp.net when use template inside repeater gridview add textboxes, , reasons fail automatically give diferent id textboxes, , have same id.
here code sould gridview must make avoid issue: http://jsfiddle.net/b7egj/2/ (with ids diferent)
Comments
Post a Comment