简体   繁体   English

jQuery datetimepicker在asp.net主页中不起作用

[英]jQuery datetimepicker not working in asp.net master page

In asp.net master page I added the following in head: 在asp.net主页中,我在标题中添加了以下内容:

<link href="~/Content/jquery-ui-timepicker-addon.css" rel="stylesheet" />
 <script src="<%: ResolveUrl("~/Scripts/jquery-1.8.2.min.js")%>"></script>
    <script src="<%: ResolveUrl("~/Scripts/jquery-ui-1.8.24.min.js")%>"></script>
    <script src="<%: ResolveUrl("~/Scripts/jquery-ui-timepicker-addon.js")%>"></script>
    <script src="<%: ResolveUrl("~/Scripts/jquery-ui-sliderAccess.js")%>"></script>

I've created a web page with master page and added the following within the contenct3: 我创建了一个包含母版页的网页,并在contenct3中添加了以下内容:

<input runat="server" type="text" id="date_begin" value=""/> 

And added the script within the head content as follows: 并在头内容中添加了脚本,如下所示:

<script type="text/javascript">
  $(document).ready(function () {
    $('#date_begin,#date_end').datetimepicker();
});
</script>

But it shows an error in the console as follows: 但它在控制台中显示如下错误:

Uncaught TypeError: $(...).datetimepicker is not a function 未捕获的TypeError:$(...)。datetimepicker不是函数

Same thing I did without using master page and working fine. 我在不使用母版页的情况下也做了同样的事情并且工作正常。

With jquery-ui you can just initialize datepicker like this : 使用jquery-ui,您可以像这样初始化datepicker:

$("#example").datepicker()

Try this link for more informations: http://trentrichardson.com/examples/timepicker/ 请尝试此链接以获取更多信息: http : //trentrichardson.com/examples/timepicker/

It is just "datepicker" 只是“日期选择器”

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.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>
  $( function() {
    $( "#datepicker" ).datepicker();
  });
</script>

Official site: http://jqueryui.com/datepicker/ 官方网站: http//jqueryui.com/datepicker/

Make sure you use the newest jquery version too. 确保您也使用最新的jquery版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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