Last post Apr 08, 2015 09:44 PM by Krunal Parekh
Apr 06, 2015 09:49 AM|holtzy7|LINK
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
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
Apr 08, 2015 02:51 AM|Krunal Parekh|LINK
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.
Apr 08, 2015 07:55 AM|holtzy7|LINK
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.
Apr 08, 2015 09:44 PM|Krunal Parekh|LINK
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.