gpt4 book ai didi

asp.net - 如何在母版页和内容页中分别使用Ajax ScriptManager和ToolkitScriptManager而不出错

转载 作者:行者123 更新时间:2023-12-02 10:10:46 24 4
gpt4 key购买 nike

由于我的页面使用 ajax,因此我的母版页中有一个 Ajax 脚本管理器。但在我的内容页面之一中,我需要在 AjaxControlToolkit 中使用 AutoCompleteExtender,这需要使用工具包中提供的 ToolScriptManager。但这会导致错误:只能将 ScriptManager 的一个实例添加到页面。我在互联网上搜索了解决方案。许多程序员建议使用 ScriptManagerProxy 来解决这个问题。另一种选择是在母版页中使用 ToolscriptManager 而不是 ScriptManager。任何人都可以演示如何使用 ScriptManagerProxy 解决此问题,因为我认为这是解决问题的更好方法?

这是我的母版页的代码:

<form runat="server" id="bodyForm">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:ContentPlaceHolder ID="ContentPlaceHolderBodyMain" runat="server">
</asp:ContentPlaceHolder>
</form>

这是我的内容页面的代码:

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="TextBoxStudentID" runat="server" autocomplete="off"></asp:TextBox>
<asp:AutoCompleteExtender ID="AutoCompleteExtenderStudentID" runat="server"
EnableCaching="true" BehaviorID="AutoCompleteEx" MinimumPrefixLength="2"
TargetControlID="TextBoxStudentID" ServicePath="~/CampusMateWebService.asmx" ServiceMethod="GetCompletionListForStudentID"
CompletionInterval="50" CompletionSetCount="30"
CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true">
<Animations>
<OnShow>
<Sequence>
<%-- Make the completion list transparent and then show it --%>
<OpacityAction Opacity="0" />
<HideAction Visible="true" />

<%--Cache the original size of the completion list the first time
the animation is played and then set it to zero --%>
<ScriptAction Script="// Cache the size and setup the initial size
var behavior = $find('AutoCompleteEx');
if (!behavior._height) {
var target = behavior.get_completionList();
behavior._height = target.offsetHeight - 2;
target.style.height = '0px';
}" />
<%-- Expand from 0px to the appropriate size while fading in --%>
<Parallel Duration=".2">
<FadeIn />
<Length PropertyKey="height" StartValue="0"
EndValueScript="$find('AutoCompleteEx')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<%-- Collapse down to 0px and fade out --%>
<Parallel Duration=".2">
<FadeOut />
<Length PropertyKey="height" StartValueScript=
"$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</asp:AutoCompleteExtender>

最佳答案

我在从旧版本的 AjaxControlToolkit 更新(以及从 .NET 2.0 升级到 3.5)时遇到了类似的问题。

Another alternative is using ToolscriptManager in the master page instead of ScriptManager. Can anyone please demonstrate how to solve this issue by using ScriptManagerProxy since I think that is a better way of solving the issue?

我不明白为什么这是更好的方法。然后,您需要在每个子页面上放置一个 ScriptManager。仅在母版页上将 ScriptManager 替换为 ToolkitScriptManager 并完成它有什么问题吗?

这是在 http://www.asp.net/ajaxlibrary/act_faq.ashx 上找到的:

  1. What is the difference between the ScriptManager control and the ToolkitScriptManager control? We recommend that you use the ToolkitScriptManager control when using the Ajax Control Toolkit. The ToolkitScriptManager uses a later version of ASP.NET Ajax than the ScriptManager control. Also, the ToolkitScriptManager performs automatic script combining on the server. You are required to use the ToolkitScriptManager when using the Ajax Control Toolkit with ASP.NET 3.5

关于asp.net - 如何在母版页和内容页中分别使用Ajax ScriptManager和ToolkitScriptManager而不出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12262910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com