【问题标题】:ASP:ScriptManager, what is that?ASP:ScriptManager,那是什么?
【发布时间】:2014-05-22 01:59:18
【问题描述】:

我希望可以发布第三个后续问题。原始问题可以在这里找到:jQuery DatePicker not working with Masterpage

经过很长时间的调查,结果证明 JavaScript 代码没有任何问题。相反,当您使用现有模板在 Visual Studio 中创建新项目时会出现问题(我使用的是 2013),在 Masterpage 中,您会发现一堆代码如下:

<asp:ScriptManager runat="server">
        <Scripts>
            <%--Framework Scripts--%>
            <asp:ScriptReference Name="MsAjaxBundle" />
            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="bootstrap" />
            <asp:ScriptReference Name="respond" />
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
            <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
            <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
            <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
            <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
            <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
            <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
            <asp:ScriptReference Name="WebFormsBundle" />
            <%--Site Scripts--%>
        </Scripts>
    </asp:ScriptManager>

当我删除上面的全部代码时,我所有的 jQuery 函数似乎都“神奇地”重新工作了。

现在我的问题是:

  1. ScriptManager 有什么用?
  2. 为什么它会影响我的 jQuery UI DatePicker?
  3. 如果我删除这些行,它将如何影响项目?
  4. 如果是,我该如何解决这些问题?

【问题讨论】:

  • 你是否包含了 jQuery 两次? ScriptManager 看起来已经为您包含了 jQuery。

标签: c# asp.net


【解决方案1】:
  1. 它负责为您的页面绑定 JavaScript 文件See here
  2. 可能有很多原因,您必须检查并查看您选择的 js 调试器中抛出的错误。所有浏览器现在都有一天
  3. 很难说,对你的项目一无所知
  4. 见#3

【讨论】:

  • 它仍然没有解释为什么删除 ScriptManager 会使 jQuery 函数再次工作。另外,我用 js 调试器进行了测试,没有抛出错误
【解决方案2】:

脚本管理器是一种包含和管理脚本文件的 .net 方式。我会说它们不在脚本管理器的预期目录中,因为前 4 个没有文件路径。

我会说将路径添加到其中的前 4 个,然后看看他们是否能够找到文件。

这里有几个使用脚本管理器的示例/教程,可以让您更好地了解 one simple ajax example

the complicated extended explanation from asp.net

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-04
    • 2017-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多