1,105,578 Community Members

Using TrackFocus(), keeping focus in TabContainer on PostBack

Member Avatar
nickg21
Newbie Poster
22 posts since Nov 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey everybody,

I've been scouring the internet and forums for days now trying to solve this issue, that seems to me like it should be pretty simple. Basically I have a multi-step form with multiple tabs in a TabContainer. There are a couple radiobuttonlists that perform autopostbacks, and I want to let the users focus go back on the radiobuttonlist so that they aren't sent back to the top of the page and lose their page state.

I have tried all of the usual stuff using SetFocus() on a control, or a certain item in the radiobuttonlist. Have used the .focus() command on every control as well as HiddenFields, and textboxes with visible="false" just to try to get the user back to that area of the page. Have also tried to set the focus to a button, all to no avail.

I'm beginning to think this is because they are located inside of a TabContainer and TabPanel, which still seems a little ridiculous to me. Everything I read keeps saying TrackFocus() has been implemented since .Net 2.0 but there is no documentation or implementation work for it anywhere. Does anyone have a suggestion for me how to approach this. I'll put up a little bit of code but basically it's in the Page_Load()

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            
            TabContainer1.ActiveTabIndex = 0
        Else
            If radInqRel.SelectedIndex = 3 Then
                ModalPopupExtender1.Show()
            ElseIf radInqRel.SelectedIndex = 2 Then
                MoreInfo.Visible = False
            End If
            txtFocus.Focus()
        End If
    End Sub

That is basically what I am trying to do, if it's a postback then set the focus to a control. I'd prefer to use the TrackFocus() to be sure that the postback goes right back to the proper place on the page, but just getting the user to the vicinity will suffice if need be. I'm not very fluent in javascript, even though most suggest using it, I just assumed that by now Microsoft would have this implemented properly. Seems like a simple thing, but certainly isn't. Thanks for any help in advance.

NickG

Here's the radiobuttonlist code;

<asp:Panel runat="server">
                    <asp:RadioButtonList ID="radInqRel" OnSelectedIndexChanged="radInqRel_SelectedIndexChanged" runat="server" RepeatColumns="2" 
                        Width="500px" CssClass="style66" AutoPostBack="True">
                        <asp:ListItem>a. Patient - Self</asp:ListItem>                    
                        <asp:ListItem>b. Family / Friend</asp:ListItem>                    
                        <asp:ListItem>c. Clinician, McLean</asp:ListItem>                    
                        <asp:ListItem>d. Clinician, outside McLean</asp:ListItem>                    
                        <asp:ListItem>e. Other (e.g. Court, lawyer)</asp:ListItem>                    
                    </asp:RadioButtonList>
                <asp:TextBox ID="txtFocus" runat="server" Visible = "False"></asp:TextBox>

<asp:HiddenField ID="HiddenField1" runat="server" />
</asp:Panel>

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: