我在生产环境中遇到了AjaxToolkit Calendar的显示错误。但是在本地调试时,这个问题不存在,日历日期选择器可以完美工作。其他所有帖子都围绕着这个工具包根本无法使用展开。我很担心为什么测试可以正常工作,但是在生产环境中却不能。因为我找不到任何在我的代码中使用ASP.NET ScriptManager的参考。
以下内容在“Site.Master”上:
<ajaxToolKit:ToolkitScriptManager runat="server">
<Scripts>
<%--Framework Scripts--%>
<%--<asp:ScriptReference Name="jquery" />--%>
<%--<asp:ScriptReference Name="jquery.ui.combined" />--%>
<asp:ScriptReference Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/MenuStandards.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/GridView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/DetailsView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/TreeView.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/WebParts.js" />
<asp:ScriptReference Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</ajaxToolKit:ToolkitScriptManager>
这是一个使用日历功能并将Site.Master作为其MasterPageFile的页面。
<asp:Label ID="DateRangeLabel" runat ="server" Text="Date Range: "></asp:Label>
<asp:TextBox ID="DateFrom" runat="server" Width="95px"></asp:TextBox>
<ajaxtoolkit:calendarextender ID="Calendarextender" runat="server" TargetControlID="DateFrom" PopupPosition="BottomLeft" Format="MM/dd/yyyy"></ajaxtoolkit:calendarextender>
<asp:TextBox ID="DateTo" runat="server" Width="95px"></asp:TextBox>
<ajaxtoolkit:calendarextender ID="Calendarextender1" runat="server" TargetControlID="DateTo" PopupPosition="BottomLeft" Format="MM/dd/yyyy"></ajaxtoolkit:calendarextender>
这是我的Web.config文件的一部分。
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
这是在生产环境中生成的错误:
Uncaught Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the ToolkitScriptManager in AjaxControlToolkit.dll.
Uncaught TypeError: undefined is not a function MicrosoftAjax.js:6