“只能将 ScriptManager 的一个实例添加到页面中。”当我将脚本管理器添加到 AJAX 工具包的密码强度时出现此错误。
我在我的 createuserwizard 的密码字段旁边添加了密码强度。 当这是我网站中唯一的脚本管理器时,为什么会出现此错误?
代码如下:
<asp:TextBox runat="server" ID="Password" TextMode="Password" MaxLength="20" />
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:PasswordStrength ID="Password_PasswordStrength" runat="server"
Enabled="True" TargetControlID="Password" DisplayPosition="RightSide"
StrengthIndicatorType="BarIndicator"
BarBorderCssClass="barBorder"
BarIndicatorCssClass="barInternal">
</asp:PasswordStrength>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password"
ErrorMessage="Password is required." />
</ContentTemplate> </asp:UpdatePanel>
</td>
</tr>
最佳答案
只要删除这个 ScriptManager,它就可以正常工作了。
<asp:ScriptManager ID="ScriptManager2" runat="server">
</asp:ScriptManager>
您肯定在页面或 MasterPage 的其他位置添加了 ScriptManager。
ScriptManager Control Overview
Only one instance of the ScriptManager control can be added to the page. The page can include the control directly, or indirectly inside a nested component such as a user control, content page for a master page, or nested master page. If a page already contains a ScriptManager control, but a nested or parent component needs additional features of the ScriptManager control, the component can include a ScriptManagerProxy control. For example, the ScriptManagerProxy control enables you to add scripts and services that are specific to nested components.
关于asp.net - 页面中只能添加一个 ScriptManager 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11154906/