여기 내 코드에서 하나의 사용자 정의 컨트롤을 만듭니다. autocompleteextender와 제출 버튼이있는 두 개의 텍스트 상자를 넣으십시오. 두 개의 텍스트 상자에 액세스 한 후 제출 버튼 클릭 이벤트가 발생하지 않습니다. 코드에서 무엇이 잘못 되었습니까? 제발 도와주세요. 그 후에 updatepanel을 넣으면 작동하지 않습니다. 두 개의 텍스트 상자 autopostback 속성이 true이기 때문에 업데이트 패널이 필요합니다.자동 완성 문자 및 버튼 이벤트가 updatepatel에서 실행되지 않습니다.
<asp:UpdatePanel runat="server" ID="UpQuote" UpdateMode="Always">
<ContentTemplate>
<div id="Quote">
<table>
<tr>
<td class="tbltdForQuote">
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblTitle" Text="Get an instant quote" CssClass="lblForQuote"
Font-Size="Large"></asp:Label>
</td>
</tr>
<tr>
<td class="tbltdForQuote">
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblTo" Text="Pick-up Location e.g. Heathrow" CssClass="lblForQuote"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="txtTo" AutoPostBack="true" autocomplete="off" CssClass="txtBoxForQuote" />
<ajaxToolkit:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx1" ID="autoComplete1"
TargetControlID="txtTo" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList"
MinimumPrefixLength="1" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20"
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('AutoCompleteEx1');
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('AutoCompleteEx1')._height" />
</Parallel>
</Sequence>
</OnShow>
<OnHide>
<%-- Collapse down to 0px and fade out --%>
<Parallel Duration=".4">
<FadeOut />
<Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx1')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</ajaxToolkit:AutoCompleteExtender>
</td>
</tr>
<tr>
<td class="tbltdForQuote">
</td>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblFrom" Text="Drop-off Location e.g.E1 (Postcode)"
CssClass="lblForQuote"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtFrom" AutoPostBack="true" runat="server" autocomplete="off" CssClass="txtBoxForQuote" />
<ajaxToolkit:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx" ID="AutoCompletetxtFrom"
TargetControlID="txtFrom" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList"
MinimumPrefixLength="1" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20"
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 />
<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="1">
<FadeOut />
<Length PropertyKey="hight" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
</Parallel>
</OnHide>
</Animations>
</ajaxToolkit:AutoCompleteExtender>
</td>
</tr>
<tr>
<td class="tbltdForQuote">
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="btnQuoteSubmit" Text="Get Quote >>" UseSubmitBehavior="false"
CssClass="QuoteButton" OnClick="btnQuoteSubmit_Click" CausesValidation="false" />
</td>
</tr>
<tr>
<td style="float: right">
<asp:HyperLink runat="server" ID="HyLogin" Text="Login to your account >>"></asp:HyperLink>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
긴 검색 후에 대답을 찾았습니다. 기본적으로 autocompleteextender는 사용자 정의 컨트롤에서 작동하지 않습니다. 그들은 webmethod를 사용하고 있기 때문에 사용자 컨트롤이 아닌 웹 페이지에서만 작동합니다. –