question

LucasDemetrius-1800 avatar image
0 Votes"
LucasDemetrius-1800 asked LanHuang-MSFT answered

Ajuda com TabContainer e TabPanel

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?

dotnet-aspnet-webforms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

LanHuang-MSFT avatar image
0 Votes"
LanHuang-MSFT answered

Hi @LucasDemetrius-1800,
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.