(I'm running on Visual Studio 2008 (ASP:NET 3.5) with the development web server)
I have the an asp.net page where:
There is a SliderExtender control inside an UpdatePanel.
Server side I'm catching the Changed event for the slider.
User can change slider value and everything work fine.
The problem
The user can use the arrow to change slider's value but when he leaves the arrow down for a while, a "Invalid ViewState
" exception raises.
Invalid viewstate.
Client IP: 127.0.0.1
Port:
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; InfoPath.2; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
ViewState: /wEPDwXJja...
I've tried on Chrome an IE8 with same results.
I understand it happens because the server side Changed
method is called again and again and time comes when the server processing speed is beaten by the incoming calls.
The question
How can I avoid this problem to happen?
What have I tried?
- Most popular suggestions on this question.
- Override page render to put ViewState at top.
- Stablish a ViewStateUserKey.
- Disable form till window loads.
- Setting a machine key.
EDIT
This is the code:
<asp:TextBox runat="server" ID="txtSlider" AutoPostBack="true" Text="100" OnTextChanged="txtSlider_TextChanged"></asp:TextBox>
<asp:SliderExtender ID="sldSlider" Decimals="0" TargetControlID="txtSlider" Length="50"
BoundControlID="lblProporcion" runat="server" Minimum="0" Maximum="100" >
</asp:SliderExtender>
protected void txtSlider_TextChanged(object sender, EventArgs e)
{
//Server processing, UpdatePanel's update....
}
When the user move the slider changing its value, txtSlider's text property changes this raising the txtSlider_TextChanged
event. I think I could use a HiddenField to store the last time I postback and use that at client side to define if txtSlider postbacks or not (if at least 500ms has passed then go ahead and postback).
I'm working on that last approach, I'll let you know if I manage to solve this thing.