I figured it out. The content was in a panel that wasn't set visible until after the code that set the HtmlElement's visibility. Here's example code replicating what I was experiencing allowing to toggle back and forth between setting the parent panel visibility before or after setting the HtmlElement visibility.
I created a sample page, but for some unknown reason, these forums won't allow me to save the post if I include the aspx lines for the buttons. I've been trying for 40 minutes now.
Here's everything, but you'll have to put your own buttons on the aspx one called b_Visible Text="Visible", the other called b_Hidden with Text="Hide" with the appropriate OnClick events below the CheckBox.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html>
<html>
<body>
<form id="form1" runat="server">
<asp:Panel runat="server" ID="p_ParentPanel" Visible="false">
<table>
<tr runat="server" id="tr_1">
<td>I'm Visible!</td>
</tr>
</table>
<asp:Label runat="server" ID="l_Test" Text="Label Visible!" />
</asp:Panel>
<hr />
<div>
HTMLElement Current State:
<asp:Label runat="server" ID="l_tr_ReportedState" Text="" />
should be
<asp:Label runat="server" ID="l_tr_ShouldBe" Text="" />
</div>
<hr />
<div>
Label Current State:
<asp:Label runat="server" ID="l_l_ReportedState" Text="" />
should be
<asp:Label runat="server" ID="l_l_ShouldBe" Text="" />
</div>
<hr />
<asp:CheckBox ID="cb_PreSetPanel" runat="server" Text="Set panel visibility first" /><br />
<!-- Place buttons here due to incredibly broken website -->
</form>
</body>
</html>
using System;
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void b_Visible_Click(object sender, EventArgs e)
{
HideStuff(true);
}
protected void b_Hidden_Click(object sender, EventArgs e)
{
HideStuff(false);
}
private void HideStuff(bool visible)
{
if(cb_PreSetPanel.Checked)
p_ParentPanel.Visible = visible; // If I make the parent panel visible first, it gives expected results
tr_1.Visible = visible;
l_Test.Visible = visible;
l_tr_ShouldBe.Text = visible.ToString();
l_tr_ReportedState.Text = tr_1.Visible.ToString();
l_l_ShouldBe.Text = visible.ToString();
l_l_ReportedState.Text = l_Test.Visible.ToString();
if(!cb_PreSetPanel.Checked)
p_ParentPanel.Visible = visible; // Order of operations of parent panel is apparently the culprit
b_Visible.Enabled = !visible;
b_Hidden.Enabled = visible;
}
}