[英]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控件时,使内容页面和用户控件之类的嵌套组件可以向页面添加脚本和服务引用。
For more info: 有关更多信息:
消息很清楚,请在母版页中定义脚本管理器,然后使用该母版页将其从所有页中删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.