本文介绍了Dropdowncheckboxes和datepicker不在同一个aspx页面上一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是,当我使用DropDownCheckBoxesLab和文本框来显示日历((。。startDate)。datepicker)时,日历不会弹出/打开以选择日期。但是,如果我从代码中删除DropDownCheckBoxesLab,那么日历就可以了。使用两者是否存在兼容性问题,或者我在这里遗漏了什么?



这是我的代码:



I'm facing an issue that when I use DropDownCheckBoxesLab and a textbox to display calendar ((".startDate").datepicker) then calendar does not popup/opens to select date. However if I remove DropDownCheckBoxesLab from code, then the calendar works. Is there any compatibility issue using both or am I missing something here?

Here is my code:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript" language="javascript">
    $(function () {
        $(".startDate").datepicker({
            changeMonth: true,
            changeYear: true,
            buttonImage: "/images/calendar.gif",
            dateFormat: "dd-M-yy",
        });
    });
</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>

    <table width="100%" cellpadding="2" cellspacing="2">
        <tr>
            <td align="left" >
                <cc1:DropDownCheckBoxes ID="DropDownCheckBoxesLab" runat="server" 
                    ToolTip="Select Program" AddJQueryReference="True" 
                    RepeatDirection="Horizontal" UseButtons="False" UseSelectAllNode="True" AutoPostBack="true"  onselectedindexchanged="DropDownCheckBoxesLab_SelectedIndexChanged">
                    <Texts SelectBoxCaption="Select Program" />
                 </cc1:DropDownCheckBoxes>
             </td>
             <td align="left">
                 <asp:TextBox ID="TextBox1" runat="server" CssClass="startDate"> </asp:TextBox>
             </td>
         </tr>
     </table>            
 </asp:Content>





我尝试将脚本部分放在asp:Content的末尾,但是结果是一样的。我在控制台中看到以下错误:



未捕获TypeError:$(...)。datepicker不是HTMLDocument中的函数

。< ;匿名> (ReportCostAndEffort.aspx:143)

at Object.resolveWith(WebResource.axd?d = iznuS5Sosk1 ... 00:16)

at Function.ready(WebResource.axd ?d = iznuS5Sosk1 ... 00:16)
$ HTML $ b在HTMLDocument.z(WebResource.axd?d = iznuS5Sosk1 ... 00:16)



当我在代码中添加以下行代码







然后日历开始工作,但是DropDownCheckBoxes停止工作。点击DropDownCheckBoxes,没有任何反应。我在控制台中收到错误Uncaught TypeError:



未捕获的TypeError:$(...)。hitch不是DropDownScript中的函数

。 initEvents



< b>我尝试了什么:< / b>



我试过将脚本部分放在asp:Content的末尾,但结果是相同的。我在控制台中看到以下错误:



未捕获TypeError:$(...)。datepicker不是HTMLDocument中的函数

。& ; LT;匿名&安培; GT; (ReportCostAndEffort.aspx:143)

at Object.resolveWith(WebResource.axd?d = iznuS5Sosk1 ... 00:16)

at Function.ready(WebResource.axd ?d = iznuS5Sosk1 ... 00:16)
$ HTML $ b在HTMLDocument.z(WebResource.axd?d = iznuS5Sosk1 ... 00:16)



当我在代码中添加以下行时

< script src =js / jquery-1.10.2.jstype =text / javascript>





然后日历开始工作,但DropDownCheckBoxes停止工作。点击DropDownCheckBoxes,没有任何反应。我在控制台中收到错误Uncaught TypeError:



未捕获的TypeError:$(...)。hitch不是DropDownScript中的函数

。 initEvents



I tried by placing the script section at the end of asp:Content, but results are same. I see below error in console:

Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.<anonymous> (ReportCostAndEffort.aspx:143)
at Object.resolveWith (WebResource.axd?d=iznuS5Sosk1...00:16)
at Function.ready (WebResource.axd?d=iznuS5Sosk1...00:16)
at HTMLDocument.z (WebResource.axd?d=iznuS5Sosk1...00:16)

When i added below lines in code



then calendar started working, but DropDownCheckBoxes stopped working. On click of DropDownCheckBoxes, nothing happens. I get error Uncaught TypeError in console:

Uncaught TypeError: $(...).hitch is not a function
at DropDownScript.initEvents

<b>What I have tried:</b>

I tried by placing the script section at the end of asp:Content, but results are same. I see below error in console:

Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.&lt;anonymous&gt; (ReportCostAndEffort.aspx:143)
at Object.resolveWith (WebResource.axd?d=iznuS5Sosk1...00:16)
at Function.ready (WebResource.axd?d=iznuS5Sosk1...00:16)
at HTMLDocument.z (WebResource.axd?d=iznuS5Sosk1...00:16)

When i added below lines in code
<script src="js/jquery-1.10.2.js" type="text/javascript">


then calendar started working, but DropDownCheckBoxes stopped working. On click of DropDownCheckBoxes, nothing happens. I get error Uncaught TypeError in console:

Uncaught TypeError: $(...).hitch is not a function
at DropDownScript.initEvents

推荐答案






我尝试将脚本部分放在asp:Content的末尾,但是结果是一样的。我在控制台中看到以下错误:



未捕获TypeError:



I tried by placing the script section at the end of asp:Content, but results are same. I see below error in console:

Uncaught TypeError:



这篇关于Dropdowncheckboxes和datepicker不在同一个aspx页面上一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 17:01