【问题标题】:ScriptManager in Master page and Content page母版页和内容页中的 ScriptManager
【发布时间】:2014-07-09 15:36:48
【问题描述】:

我有一个关于 Scriptmanager 的问题,我的问题是: 为此,我需要在母版页中使用 ScriptManager:

<asp:ScriptManager ID="scriptManger1" runat="server">
    <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" />
    </Scripts>
</asp:ScriptManager>

并且我在我的内容页面中需要一个 ScriptManager,因为如果我在运行我的应用程序时从这里删除,会给我一个错误,因为我需要一个 ScriptManager,如果我在运行我的应用程序时放置一个 ScripManager,会给我一个错误,因为我有2 ScriptManager,因为我在母版页中有 1 个,在内容页中有 1 个。

我的问题是如何解决这个问题?

【问题讨论】:

  • 您遇到的具体错误是什么?
  • 这里的标签在哪里,请标记一下¿?

标签: c# asp.net


【解决方案1】:

您是对的,您只能拥有 1 个 ScriptManager。这绝对应该放在您的母版页中。要在您的其他页面中获得 ScriptManager 功能,您需要使用 ScriptManagerProxy。将此代理视为将对其发出的所有请求分叉到加载在母版页中的真实 ScriptManager。

把这个小家伙扔到你的其他页面:

 <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server"/>

以下是关于如何更详细地应用它的好读物:

http://www.dotnetheaven.com/article/ajax-package-scriptmanagerproxy-control-in-asp.net-using-vb.1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-02-12
    • 2012-11-14
    • 1970-01-01
    • 2013-02-08
    • 2012-08-29
    • 2014-02-02
    • 1970-01-01
    相关资源
    最近更新 更多