0

I'm using JQueryUi datepicker in ASP.NET Dynamic Data. Some forms have more than one datetime field. But datepicker works for the first one and the other fields don't show datepicker. How can I fix this problem?

<script type="text/javascript">
$(document).ready(function () {
    $('#<%=TextBox1.ClientID %>').datepicker({
        showOn: "button",
        buttonImage: "../images/calendar.gif",
        buttonImageOnly: true
    }).regional['fa'];
});

Karadous
  • 1,555
  • 3
  • 26
  • 37
  • Please provide your code sample. – sarwar026 May 11 '12 at 13:43
  • 1
    @Karadous this code is to set it only on TextBox1 control. You need to add more code for more controls, or use the css to attach many datepicker to many controls – Aristos May 11 '12 at 13:51
  • As you can see jquery selector is applied to client id. so every text box will have it's own client id. As I mentioned when I don't use .regional['fa'] it works fine. Regional has a problem here. – Karadous May 11 '12 at 19:25

1 Answers1

0

This line $('#<%=TextBox1.ClientID %>'). assign the DatePicker to the input with the ID=TextBox1 and only to this one, so its work as you say.

To add more DatePickers you can add more lines with the rest controls that you wish to use the DatePicker, or set the same css on this control you with to attact the DatePicker and change the code to $('.DateKeeperCss'). where you set the DateKeeperCss style to all Text Editors that you wish to have the DatePicker. For example:

$(document).ready(function () {
    $('.DateKeeperCss').datepicker({
        showOn: "button",
        buttonImage: "../images/calendar.gif",
        buttonImageOnly: true
    }).regional['fa'];
});

and

<asp:TextBox runat="server" ID="TextBox1" CssClass="DateKeeperCss"></asp:TextBox>
<asp:TextBox runat="server" ID="TextBox2" CssClass="DateKeeperCss"></asp:TextBox>
<asp:TextBox runat="server" ID="TextBox3" CssClass="DateKeeperCss"></asp:TextBox>
<asp:TextBox runat="server" ID="TextBox4" CssClass="DateKeeperCss"></asp:TextBox>
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • Text boxes are created dynamically. As I mentioned I'm using ASP.Net Dynamic Data. I recognized that when I remove ".regional['fa']" every thing goes ok. I tested other regional files like fr. It hase this problem too – Karadous May 11 '12 at 14:13
  • if you create them dynamically then assign then the cssclass. – Aristos May 11 '12 at 14:16
  • As you can see jquery selector is applied to client id. so every text box will have it's own client id. As I mentioned when I don't use .regional['fa'] it works fine. Regional has a problem here. – Karadous May 11 '12 at 19:24
  • Solved. Regional files have problem. I changed my calendar and the problem solved – Karadous May 12 '12 at 17:23