asp.net jquery 日期选择器不起作用

asp.net jquery datepicker not working

本文关键字:选择器 不起作用 日期 jquery net asp      更新时间:2023-09-26

我是javascript和Jquery的新手,我似乎无法做到这一点。我相信具体问题是对 jquery 文件的引用不起作用,但我可能是错的。下面是相关代码。

<head runat="server">
<title>Expense Report Admin Portal</title>
<link rel="stylesheet" type="text/css" href="Content/admin.css" />
<%--<script type="text/javascript" src="Scripts/jquery-ui-1.11.4/jquery-ui.js"></script>--%> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui.min.js"></script>

<script>
$(function() {
  $( '#<%=datepicker.ClientID%>' ).datepicker();
});
</script>
</head>

<asp:TableCell>
      <asp:TextBox ID="datepicker" runat="server"></asp:TextBox>
                            </asp:TableCell>

我是对的,jquery引用有问题。我接受了上面 Igor 的建议,虽然我没有复制所有代码,但我确实用示例中的引用替换了我对 jquery 的所有引用,并且它有效。

我想你评论jquery参考。 取消注释此行。 Belwo 示例对我有用。

include => jquery-ui.css include => jquery-1.10.2.js include => jquery-ui.js

<!doctype html>
 <html lang="en">
 <head>
   <meta charset="utf-8">
   <title>jQuery UI Datepicker - Default functionality</title>
  <link rel="stylesheet" href="http://code.jquery.com 
  ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
   <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js">
 </script>
 <link rel="stylesheet" href="/resources/demos/style.css">
  <script>
   $(function() {
     $( "#datepicker" ).datepicker();
  });
   </script>
</head>
<body>
 <p>Date: <input type="text" id="datepicker"></p>

 </body>
 </html>