I have a WebTab control on MyPage.aspx. The WebTab control contains two tabs. The same User Control is used on both tabs. How can I identify which tab I'm on from within the User Control's code behind page? (MyUserControl.ascx.vb) - I need to know whether I'm on Tab1 or Tab2.
Here's the markup for the WebTab -
<ig:WebTab ID="WebTab1" runat="server" Height="600px" SelectedIndex="1" Width="848px"> <tabs> <ig:ContentTabItem runat="server" Text="Tab1" UserControlUrl="MyUserControl.ascx"> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab2" UserControlUrl="MyUserControl.ascx"> </ig:ContentTabItem> </tabs></ig:WebTab>
Thanks - Ed
Hi Anthony,
The UserControlUrl should be a child (grand-grand-..-child) of ContentTabItem and ContentTabItem should be a child (grand-grand-..-child) of WebTab. It means that you always may identify to which exactly tab-item and WebTab belongs a particular UserControl. I guess, similar search should be applied to any "unknown" container of UserControl. I am not expert in vb, so I wrote cs codes for you, which show how to find parent tab-item and its WebTab. The vb should be very similar.
protected void Page_Load(object sender, EventArgs e) { Control ctrl = this; while (ctrl != null) { ctrl = ctrl.Parent; if (ctrl is Infragistics.Web.UI.LayoutControls.ContentTabItem) { Infragistics.Web.UI.LayoutControls.ContentTabItem tab = (Infragistics.Web.UI.LayoutControls.ContentTabItem)ctrl; int index = tab.Index; string text = tab.Text; string key = tab.Key; while (ctrl != null) { ctrl = ctrl.Parent; if (ctrl is Infragistics.Web.UI.LayoutControls.WebTab) { Infragistics.Web.UI.LayoutControls.WebTab webTab = (Infragistics.Web.UI.LayoutControls.WebTab)ctrl; int selected = webTab.SelectedIndex; } } } } }
WebTab.SelectedIndex not working?