Share via

Ajuda com TabContainer e TabPanel

Lucas Demetrius 21 Reputation points
2022-05-08T10:33:03.16+00:00

Olá pessoal, estou precisando da ajuda de vocês.

Tenho uma página asp.net(webforms) com os seguintes controles:
1 TabContainer e 4 TabPanel

Dentro do primeiro TabPanel1 tenho um controle do tipo Edit1.text, quando digito algo dentro dele tento estabelecer o focus no Edit2, mas não esta dando certo, vou deixar aqui minhas tentativas

//Já tentei estabelecer o focus usando findControl
TextBox MyTextBox = (TextBox)((TextBox)sender).FindControl("Edit2");
MyTextBox.Text = "Hello";
MyTextBox.Focus();
Obs:O texto "Hello" funciona mas o Focus() não funciona

//Já tentei
TabContainer tb = ((TabContainer)this.TabContainer1.FindControl("TabContainer1"));
TabPanel tp = ((TabPanel)tb.FindControl("TabPanel1"));
((TextBox)tp.FindControl("Edit2")).Text = "TesteFocus";
((TextBox)tp.FindControl("Edit2")).Focus();

Tentei algumas funções JS mas sem sucesso.

Alguém já passou por isso?

Poderia ajudar?

Developer technologies | ASP.NET Core | Other
0 comments No comments

Answer accepted by question author

  1. Lan Huang-MSFT 30,211 Reputation points Microsoft External Staff
    2022-05-09T06:25:17.21+00:00

    Hi @Lucas Demetrius ,
    Maybe you can use JavaSc ript to achieve this.

     function pageLoad() {  
                $get("<%=TextBox1.ClientID %>").focus();  
            }  
    

    Please refer to the following examples:

     <form id="form1" run at="ser ver" >  
            <div>  
            <asp:Scr iptManager ID="ToolkitSc riptManager1" runat="server">  
            </asp:Sc riptManager>  
            <asp:TabContainer ID="TabContainer1" runat="server" Width="100%" >  
                <asp:TabPanel runat="server" ID="TabPanel1" HeaderText="11111">  
                    <ContentTemplate>  
                <asp:TextBox ID="TextBox1" runat="server" Text="123"></asp:TextBox>  
                    </ContentTemplate>  
                </asp:TabPanel>  
            </asp:TabContainer>  
            </div>  
        </form>  
    <scr ipt type="text/javasc ript">   
        function pageLoad() {  
            $get("<%=TextBox1.ClientID %>").focus();  
        }  
    </scr ipt>  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.