繁体   English   中英

主页面和内容页面中的ScriptManager

[英]ScriptManager in Master page and Content page

我有一个关于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个。

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

你是对的,你只能有一个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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM