ページで ajax を使用しているため、マスター ページに Ajax スクリプト マネージャーがあります。しかし、コンテンツ ページの 1 つで、AjaxControlToolkit で AutoCompleteExtender を使用する必要があります。これには、ツールキットで利用可能な ToolScriptManager を使用する必要があります。ただし、これにより、 ScriptManager のインスタンスを 1 つだけページに追加できるというエラーが発生します。インターネットで解決策を探しました。多くのプログラマーは、この問題を解決するために ScriptManagerProxy の使用を提案しています。もう 1 つの方法は、ScriptManager の代わりにマスター ページで ToolscriptManager を使用することです。問題を解決するためのより良い方法だと思うので、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>