I know how to hide a tab:
MyTabContainerID.Tabs[1].Visible = false;
That works. What I’m having trouble with is changing the visibility of a tab triggered by the postback of a radioButtonList selectedIndexChanged event.
By the time the page reaches my selectedIndexChanged event handler the tab has already loaded Visible=True from the ViewState. I can change it to false all day long in my selectedIndexChanged event, it won’t hide the tab b/c it’s already loaded.
ASPX
<asp:RadioButtonList ID="rblMyRadioButtonList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="rblMyRadioButtonList_SelectedIndexChanged">
<asp:ListItem Text="Yes" Value="True" Selected="True"></asp:ListItem>
<asp:ListItem Text="No" Value="False"></asp:ListItem>
ASCX
protected void Page_Init(object sender, EventArgs e)
{
try
{
MyTabContainerID.Tabs[1].Visible = Tab1Visibility;
}
catch (Exception ex)
{
common.alert("Error in PageName.Page_Init.<br>ERROR=" + ex.Message);
}
}
protected void rblMyRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
Tab1Visibility = Convert.ToBoolean(((RadioButtonList)sender).SelectedValue);
MyTabContainerID.Tabs[1].Visible = Tab1Visibility; //BY THE TIME THIS HAPPENS IT'S ALREADY ON THE PAGE WITH VISIBLE=TRUE
}
catch (Exception ex)
{
common.alert("Error in PageName.rblMyRadioButtonList_SelectedIndexChanged.<br>ERROR=" + ex.Message);
}
}
protected bool Tab1Visibility
{
get { return (bool)Session["ses_bTab1Visibility"]; }
set { Session["ses_bTab1Visibility"] = value; }
}
Thoughts? Suggestions?
Here’s what I ended up doing:
*.ASPX
*.ASCX on Page_Load