locked
Fast/Bulk Postback handling RRS feed

  • Question

  • User-954728493 posted

    I have a search feature that is similar to the google search autocomplete.  I have a textbox that the user enters their search criteria, then with javascript I am automatically clicking a hidden button inside an updatepanel so I can run code on the server.  This all works great until somebody leans on the keyboard and it can't handle that many postbacks is my guess (but it could be something else).

    The error I am randomly getting is "The state information is invalid for this page and might be corrupted.".

    I made it error less when I try to determine if it is in the middle of a postback by using a variable, but it still errors sometimes:

     If iDuringPostback.Value.ToString = "Yes" Then
            Else
    'Refresh Results
    End If

    Here is the code I am using to add the onKeyUp event:

    If Not IsPostBack Then
                    txtSearch.Attributes.Add("onKeyUp", "doKeyUp('" + btnSearchHidden.ClientID + "','" + iHiddenSearchValue.ClientID + "',event)")

    Adding enableeventvalidation= false in the web.config does not fix the problem.   Any ideas?

    EDIT: It appears to only be a problem in IE

    Monday, April 6, 2015 9:49 AM

Answers

  • User1644755831 posted

    Hello holtzy,

    The simplest solution I can give you is that do not post back until previous request is finished on keyup. You can just set a Boolean flag like InProgress which will be set to true on client side when you post a request to server and will be set false when it completes. then if user posts multiple times just allow only to post when Boolean value is false so postback is done only one at a time.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 8, 2015 2:51 AM
  • User1644755831 posted

    Hello Holtzy7,

    For this you could do this.

    When user start typing before the first post back save the textbox's value in a variable now after success check if the textbox's value and variable value are same if not then user must have typed more letters. now the new value with all the letters that are typed now do another request. so user get latest values and only one post back is done at a time.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 8, 2015 9:44 PM

All replies

  • User1644755831 posted

    Hello holtzy,

    The simplest solution I can give you is that do not post back until previous request is finished on keyup. You can just set a Boolean flag like InProgress which will be set to true on client side when you post a request to server and will be set false when it completes. then if user posts multiple times just allow only to post when Boolean value is false so postback is done only one at a time.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 8, 2015 2:51 AM
  • User-954728493 posted

    Thanks for the input. I ended up doing just that, but the problem is it skips the last several letters if they are typing fast (because it is still during a previous postback).  So you end up with results that do not match the full string typed in the textbox.

    Wednesday, April 8, 2015 7:55 AM
  • User1644755831 posted

    Hello Holtzy7,

    For this you could do this.

    When user start typing before the first post back save the textbox's value in a variable now after success check if the textbox's value and variable value are same if not then user must have typed more letters. now the new value with all the letters that are typed now do another request. so user get latest values and only one post back is done at a time.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 8, 2015 9:44 PM