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.

Can't publish files in Visual Studio 2012


Symptom: 
When publishing files to a local drive with Visual Studio 2012, there seems to be no files in the destination directory.

Additional Symptoms:
- The My Project folder has some read-only .pubxml files that contain settings for publishing.  Deleting them seems to make deploying work again.
- After a Get Latest from TFS, my previously successful Publish settings are overridden with another team member's settings.

Solution:
When publishing a project, give the profile name something unique like your own name.  This will make a seperate .pubxml file with your settings.  Other team members using unique profiles with their own names should no longer affect your settings.  When they change their profile settings, their .pubxml file will be checked out and updated accordingly.