【问题标题】:conflicting master and content page while using bootstrap使用引导程序时母版页和内容页冲突
【发布时间】:2016-09-20 05:56:40
【问题描述】:

我在 asp.net C# 中使用 Master 和 Content 页面。在我的 web 应用程序中,我正在使用引导程序。我收到错误 Uncaught TypeError: $(...).datepicker is not a function

如果我尝试解决上述错误,母版页中的下拉菜单会产生错误,因为 Uncaught TypeError: $(...).dropdown is not a function

Uncaught TypeError: $(...).datepicker is not a function (anonymous function) @ com_mst_CompanyRegistrationAdd.aspx:111 i @ jquery.min.js:2 fireWith @ jquery.min.js:2 ready @ jquery.min.js:2 K @ jquery.min.js:2

在母版页中:

<script src="../Scripts/jquery-1.12.4.js"></script>
    <script src="../Scripts/jquery-1.12.4.min.js"></script>    
    <script src="../Scripts/bootstrap.js"></script>
    <script src="../Scripts/bootstrap.min.js"></script>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
    <script>
$(document).ready(function() {
    $('dropdown-toggle').dropdown()
});
</script>

在内容页面中:

 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $("#txtEstablishedDate").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                changeYear: true,               
                });
        });
    </script>
    <script type="text/javascript">
        $(function () {

            $("#txtRCDate").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                changeYear: true
            });
        });
    </script>
    <script type="text/javascript">
        $(function () {
            $("#txtCstDate").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                changeYear: true
            });
        });

    </script>

请帮我解决错误..

【问题讨论】:

    标签: jquery twitter-bootstrap-3


    【解决方案1】:

    未捕获的类型错误。我认为您正在使用 Jquery UI 小部件。 您需要粘贴下面的脚本和下面的链接网址。

     <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>
    

    这将解决问题

    【讨论】:

    • 在我的页面中使用此代码后存在同样的错误。
    • 这个错误有几个原因: jquery.ui 在 jquery 之前使用。 $ 被另一个库使用。试试这个来整理
    猜你喜欢
    • 2013-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多