Thursday, January 24, 2013
UpdatePanel doesn't like the ViewState being tampered with!
Symptom:
Previous instances of RadAjaxPanel were replaced with UpdatePanel. Suddenly, controls within that page no longer postback.
Sample Code:
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</ContentTemplate>
</asp:UpdatePanel>
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
Button2.Text = DateTime.Now.ToString();
}
When alternating clicks between Button1 and Button2, I would expect that the clicked button would update with the current time. Instead, the button values were clearing.
Solution:
It turns out this was specific to a certain page. On a normal page, it worked fine. On the page with these symptoms, I discovered it was related to a solution that implimented due to a large ViewState. I was overriding SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium and that was causing the UpdatePanel to fail when saving the ViewState information to the Cache.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment