I use more than one TabContainer per page in an ASP.NET project, and I noticed a very strange behavior: when the page loads, the focus moves to the last TabContainer on the page, causing it to scroll down. I don’t pay attention to any control, so I don’t understand where it comes from. I also switched places between the controls, and this is always the last one that is focused. TabContainers don't have any fancy settings, this is basically what they look like:
<cc1:TabContainer ID="tabContainer" runat="server"> <cc1:TabPanel runat="server" HeaderText="Header1" ID="tabPanel1" TabIndex="0"> <HeaderTemplate> <asp:Label ID="lblTab1" runat="server" Text="Tab1"></asp:Label> </HeaderTemplate> <ContentTemplate> ... (anything goes here, it still doesn't work) </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel runat="server" HeaderText="Header2" ID="tabPanel2" TabIndex="1"> <HeaderTemplate> <asp:Label ID="lblTab2" EnableViewState="False" runat="server" Text="Tab2"></asp:Label> </HeaderTemplate> <ContentTemplate> ... (anything goes here, it still doesn't work) </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer>
I know that I can focus on the control, I tried it, but first the page scrolls into the tab container and then returns to the focused control (this doesn’t look very good). I tried this to set focus to another control:
<body id="main" onload="javascript:document.getElementById('lnkLogout').focus();">
Is this the standard behavior for TabContainer? How can I get rid of it?
source share