Async trigger for an update panel refreshes entire page when triggering too much in too short of tim

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-13T06:13:16Z Indexed on 2010/04/13 6:33 UTC
Read the original article Hit count: 447

I have a search button tied to an update panel as a trigger like so:

<asp:Panel ID="CRM_Search" runat="server">
    <p>Search:&nbsp;<asp:TextBox ID="CRM_Search_Box" CssClass="CRM_Search_Box" runat="server"></asp:TextBox>
    <asp:Button ID="CRM_Search_Button" CssClass="CRM_Search_Button" runat="server" Text="Search" OnClick="SearchLeads" /></p>
</asp:Panel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="CRM_Search_Button" />
    </Triggers>
    <ContentTemplate> 
     /* Content Here */
    </ContentTemplate>
</asp:UpdatePanel>

In my javascript I use jQuery to grab the search box and tie it's keyup to make the search button click:

    $($(".CRM_Search_Box")[0]).keyup(
        function () {
            $($(".CRM_Search_Button")[0]).click();
        }
    );

This works perfectly, except when I start typing too fast. As soon as I type too fast (my guess is if it's any faster than the data actually returns) the entire page refreshes (doing a postback?) instead of just the update panel.

I've also found that instead of typing, if I just click the button really fast it starts doing the same thing.

Is there any way to prevent it from doing this? Possibly prevent 2nd requests until the first has been completed? If I'm not on the right track then anyone have any other ideas?

Thanks,
Matt

© Stack Overflow or respective owner

Related posts about updatepanel

Related posts about triggers