Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Problems setting focus on a control in an AJAX toolkit TabContainer / TabPanel as part of a master page

$
0
0

Hopefully someone can quickly help with this one, I have spent many hours on other articles and approaches and beleive it is able to be solved using the - AjaxControlToolkit.Utility.SetFocusOnLoad method, however I am having troubles correctly referencing the FindControl, below is the code

As this page is also using a Master page, I 'm not sure how to get around accessing the HTML <body> OnLoad for a client side solution, but would prefer a server side solution if there is one.

OnLoad

' try to force focus to a control which is itself, within an AJAX tab'
        If Not (IsNothing(Session("ControlIDforFocus"))) Then
            Try

                Session("Temp") = ""
                AjaxControlToolkit.Utility.SetFocusOnLoad(FindControl("ContentMain").FindControl(Session("ControlIDforFocus")))
                Session("Temp") = "AJAX SetFocusOnLoad worked"

            Catch ex As Exception
               Session("Temp") = "AJAX default focus failed"
            End Try

            ' track which path the try logic takes'
            TempDebugLabel2.Text = Session("Temp")

        End If

**  I now know the above code is wrong, see my later reply / correction explaining how I implimented FindControl

The Page markup

<asp:Content ID="ContentMain" ContentPlaceHolderID="MainContent" runat="server">
<asp:TabContainer ID="TestCentreTabContainer" runat="server" Width="100%" 
ActiveTabIndex="3">
<asp:TabPanel runat="server" ID="DoTestTabPanel">

         ... other layers of markup tags being DIVs and other Panels etc

         <asp:Panel ID="DoTestTab_StartTestPanel" runat="server">
              ..... this panels  content, which is not needing to be referenced at all</asp:Panel><asp:Panel ID="DoTestTab_TakeTestPanel" runat="server">

                    ... other layers of markup tags being DIVs etc

                    *** I need to be able to reference / setfocus to the below control during a postback ***<asp:TextBox ID="DoTestTab_QuestionAnswerEnteredTextBox" runat="server" Width='50px'></asp:TextBox><br /></asp:Panel></asp:TabPanel>
</asp:TabContainer>
</asp:Content>     


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>