JQuery 日期选择器在 Contentpage 中不工作 ASP.Net

JQuery Datepicker not working in Contentpage ASP.Net

Datapicker 在没有母版页的情况下工作正常,但是当我使用母版页和内容页时,它在内容页中不起作用。我在母版页和内容页中为 Datapicker 使用以下代码。

在母版页的头部,我有以下代码。

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
     <script type="text/javascript">
         $(document).ready(function () {
             $("#<%=txtFromDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });
             $("#<%=txtToDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });                     
         });
    </script>
</asp:Content>
In Content Page I am writing the following code.

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
     <script type="text/javascript">
         $(document).ready(function () {
             $("#<%=txtFromDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });
             $("#<%=txtToDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });                     
         });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


<table>
    <tr>
                <td>
                    From Date
                </td>
                <td>
                    <asp:TextBox ID="txtFromDate" runat="server" Width="220" 

ClientIDMode="Static"></asp:TextBox>
                    <span id="spnPDate" class="err" />
                </td>
            </tr>
            <tr>
                <td>
                    To Date
                </td>
                <td>
                    <asp:TextBox ID="txtToDate" runat="server" Width="220" ClientIDMode="Static"></asp:TextBox>
                    <span id="spnEDate" class="err" />
                </td>
            </tr>
   </table>
</asp:Content>

如何在内容页面中使用 Datapicker?

use this I tested it

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
     <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  <link rel="stylesheet" href="/resources/demos/style.css">
     <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             $("#<%=txtFromDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });
             $("#<%=txtToDate.ClientID %>").datepicker({ dateFormat: 'dd-mm-yy' });                     
         });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


<table>
    <tr>
                <td>
                    From Date
                </td>
                <td>
                    <asp:TextBox ID="txtFromDate" runat="server" Width="220" 

ClientIDMode="Static"></asp:TextBox>
                    <span id="spnPDate" class="err" />
                </td>
            </tr>
            <tr>
                <td>
                    To Date
                </td>
                <td>
                    <asp:TextBox ID="txtToDate" runat="server" Width="220" ClientIDMode="Static"></asp:TextBox>
                    <span id="spnEDate" class="err" />
                </td>
            </tr>
   </table>
</asp:Content>