简体   繁体   English

母版页-只能将ScriptManager的一个实例添加到该页中

[英]Master page - Only one instance of a ScriptManager can be added to the page

I am using ajax toolkit in my project. 我在我的项目中使用ajax工具包。 My project is having a master page and i am inheriting this master page in my web pages.I am using Script manager on every page but now requirement came to display a real time clock also on the master page.I had written the code using Timer to display real time clock on master page but i am getting error "Only one instance of a ScriptManager can be added to the page. ". 我的项目有一个母版页,我正在Web页中继承此母版页。我在每个页面上使用脚本管理器,但现在要求也要在母版页上显示实时时钟。我已经使用Timer编写了代码在母版页上显示实时时钟,但出现错误“仅ScriptManager的一个实例可以添加到页上。”。

How to fix this problem as i don't want to remove script manager from the webpages. 如何解决此问题,因为我不想从网页中删除脚本管理器。

You can use only one ScriptManager per page 每页只能使用一个ScriptManager

But if you need to use the functionality provided by the ScriptManager for example to register custom scripts (this is really useful when you are creating server controls or working with content pages), there is one approach. 但是,如果您需要使用ScriptManager提供的功能来注册自定义脚本(这在创建服务器控件或使用内容页面时非常有用),则有一种方法。

Use the <asp:ScriptManagerProxy runat="server" /> server control instead 使用<asp:ScriptManagerProxy runat="server" />服务器控件代替

From MSDN: 从MSDN:

Enables nested components such as content pages and user controls to add script and service references to pages when a ScriptManager control is already defined in a parent element. 当父元素中已经定义了ScriptManager控件时,使内容页面和用户控件之类的嵌套组件可以向页面添加脚本和服务引用。

Source 资源

For more info: 有关更多信息:

消息很清楚,请在母版页中定义脚本管理器,然后使用该母版页将其从所有页中删除。

暂无
暂无

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

相关问题 只能将一个ScriptManager实例添加到页面中 - Only one instance of a ScriptManager can be added to the page MultiHandleSliderExtender:错误-只能将ScriptManager的一个实例添加到页面 - MultiHandleSliderExtender: Error - Only one instance of a ScriptManager can be added to the page System.InvalidOperationException:只能将ScriptManager的一个实例添加到页面 - System.InvalidOperationException: Only one instance of a ScriptManager can be added to the page 只能将ScriptManager的一个实例添加到页面中-动态数据和DateFilter - Only one instance of a ScriptManager can be added to the page - Dynamic data and DateFilter 一个 ScriptManager 的实例只能添加到 asp.net 中的页面 - Only one instance of a ScriptManager can be added to the page in asp.net 主页面和内容页面中的ScriptManager - ScriptManager in Master page and Content page 当母版页中没有ScriptManager时,从内容页更新母版页的标签 - Update label of MasterPage from content page when there is no ScriptManager in master page 我在一个Web表单上添加了一个CSS,但是它仅在我的母版页中起作用,而在特定的Web表单中不起作用 - I've added a css on one of my webform but it only works in my master page and not on specific webform 以编程方式将ScriptManager添加到页面? - Add ScriptManager to Page Programmatically? 当母版页仅允许一个路径时,如何查看pdf或jpeg? - How can either a pdf or a jpeg be viewed when master page only allows one path?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM