简体   繁体   English

主页面和内容页面中的ScriptManager

[英]ScriptManager in Master page and Content page

I have a question about Scriptmanager, my question is: I need in master page a ScriptManager for this: 我有一个关于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>

and I need in my content page a ScriptManager because if I remove from here when I run my application give me a error because I need a ScriptManager and if I put a ScripManager when I run my application give me a error because I have 2 ScriptManager because I have 1 in master page and 1 in content page. 我需要在我的内容页面中使用ScriptManager,因为如果我在运行应用程序时从此处删除,则会出现错误,因为我需要一个ScriptManager,如果我在运行应用程序时放入ScripManager,则会出现错误,因为我有2个ScriptManager因为我在主页面中有1个,在内容页面中有1个。

My question is How I fix this? 我的问题是我如何解决这个问题?

You are right that you can have only 1 ScriptManager. 你是对的,你只能有一个ScriptManager。 This should most definitely go in your master page. 这绝对应该放在你的母版页中。 To get ScriptManager functionality in your other pages, you will need to use a ScriptManagerProxy. 要在其他页面中获取ScriptManager功能,您需要使用ScriptManagerProxy。 Think of this proxy as forklifting all requests made to it to the real ScriptManager loaded in the master page. 可以将此代理视为将所有请求分叉到主页中加载的真实ScriptManager。

Toss this little guy in your other pages: 在你的其他页面扔这个小家伙:

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

Here is a good read on how to apply this in more detail: 以下是有关如何更详细地应用此内容的精彩内容:

http://www.dotnetheaven.com/article/ajax-package-scriptmanagerproxy-control-in-asp.net-using-vb.1 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