0

在我的代码中,我创建了一个用户控件。放置两个带有 autocompleteextender 和提交按钮的文本框。访问两个文本框后,提交按钮单击事件不会触发。代码有什么问题。请帮助我。当我将更新面板放在之后它不起作用。我需要更新面板,因为两个文本框自动回发属性为真。

<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>
4

2 回答 2

0

您可以尝试两件事。1.AutoPostBack="True"在您的按钮声明中设置属性。或者如果这不起作用, 2. 将按钮从更新面板中取出。

于 2012-10-29T11:24:59.810 回答
0

经过长时间的搜索,我找到了答案。基本上自动完成扩展器不能在用户控制中工作。因为他们使用 webmethod 并且它只适用于网页而不是用户控制

于 2012-11-28T06:51:14.783 回答