I do a lot of multi-table ASP.NET wizard apps, so there are typically a number of tables, tablerows or panels to manage in the course of a user going through the wizard's virtual pages. I used to manage the visibility of elements as part of the logic of the element being populated or processed, with the elements being turned on or off depending on circumstances. These .Visible statements were scattered throughout the .cs file and I didn't like that.
So I happened upon an approach which probably has been advocated (or maybe not because it isn't a best practice?) for a long time, but it works for me. Essentially, I have a single method which contains all Tables, Tablerows, or Panels. I pass to that method the table I want to turn on, or make visible. All tables in the wizard are turned off, and before leaving the method, the active table is made visible.
private void ShowTable(HtmlTable table)
{
tblCidForm.Visible = false;
tblUidSelect.Visible = false;
tblUidForm.Visible = false;
table.Visible = true;
}
protected void FillCidForm()
{
ShowTable(tblCidForm);
}