简体   繁体   中英

jquery date picker not working with master page

jQuery datepicker not working with master page. datepicker not working while master page id added.

Please find the below code for more information.

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
   <title>jQuery UI Datepicker - Default functionality</title>
   <link rel="stylesheet" ref="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
   <script src="//code.jquery.com/jquery-1.10.2.js"></script>
   <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
   <link rel="stylesheet" href="/resources/demos/style.css">
   <script>
      $(function () {
         $("#datepicker").datepicker();
      });
   </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
   <p>Date: <input type="text" id="datepicker"></p>
</asp:Content>

You need to add an attribute ClientIDMode="Static " to save the id as is.

I recommend to use class instead but not overide the server generated ID.

Like:

<input type="text" id="datepicker" class="datepicker" />

Then:

$(function () {
   $(".datepicker").datepicker();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM