Focus is not applied to a button inside a panel bar

6 posts, 0 answers
  1. Bharathwajan Venkatanarayanan
    Bharathwajan Venkatanarayanan avatar
    25 posts
    Member since:
    Aug 2009

    Posted 27 Oct 2009 Link to this post

    Hi,

    we are using a panelbar having 6 panelitems.during pageload,by default,the first panelitem will be expanded and there is a label and button control present inside it.our requirement is ,on load the focus should be on button.
    if we press enter the next panelitem should get expanded.

    my code:

    Button

     

    btnNext = (Button)pnlbarRegn.FindItemByValue("Welcome").FindControl("BtnNext");

     

    btnNext.TabIndex = 0;

    btnNext.Focus();

    need help.

    Thanks,
    Bharathwajan

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Oct 2009 Link to this post

    Hi Bharathwajan,

    Try the following code snippet in order to focus to button placed in panelbar item.

    C#:
     
    protected void Page_Load(object sender, EventArgs e) 
        if (!IsPostBack) 
        { 
            RadPanelItem item = (RadPanelItem)RadPanelBar2.FindItemByText("Welcome"); 
            Button btnNext = (Button)item.FindControl("Button1"); 
            btnNext.Focus(); 
        } 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bharathwajan Venkatanarayanan
    Bharathwajan Venkatanarayanan avatar
    25 posts
    Member since:
    Aug 2009

    Posted 27 Oct 2009 Link to this post

    Hi,

    I have tried as you suggested but it is not working.
    please see my HTML below.

    <

     

    telerik:RadPanelItem runat="server" Text="Step 1: Welcome" Font-Underline="false"

     

     

    Expanded="true">

     

     

    <Items>

     

     

    <telerik:RadPanelItem runat="server" Value="Welcome" >

     

     

    <ItemTemplate>

     

     

    <asp:Label ID="lblWelcome" runat="server" TabIndex="-1"></asp:Label>

     

     

    <table style="width: 100%">

     

     

    <tr>

     

     

    <td colspan="2" align="right">

     

     

    <table border="0" cellpadding="0" cellspacing="0" class="tbl_button">

     

     

    <tr>

     

     

    <td>

     

     

    <asp:Button ID="BtnNext" runat="server" OnClick="BtnNext_Click" Text="Next"

     

     

    CssClass="btn" />

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    </ItemTemplate>

     

     

    </telerik:RadPanelItem>

     

     

    </Items>

     

     

    </telerik:RadPanelItem>

    Please let me know whether it is feasible.

    Thanks,
    Bharathwajan

     

  5. Bharathwajan Venkatanarayanan
    Bharathwajan Venkatanarayanan avatar
    25 posts
    Member since:
    Aug 2009

    Posted 28 Oct 2009 Link to this post

    Hi,

    i am using a ajaxpanel above the panelbar.
    if i tried the focus with out ajaxpanle it is working fine but there is a full postback in the panelbar.
    if we tried with ajaxpanel , we are not able to set the focus on the button.

    Please explain how to set the focus on button in panelbar which is inside a ajaxpanel.
    please see the code below

    <

     

    telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">

     

    <

     

    telerik:RadPanelItem runat="server" Text="Step 1: Welcome" Font-Underline="false"

     

     

     

    Expanded="true">

     

     

     

    <Items>

     

     

     

    <telerik:RadPanelItem runat="server" Value="Welcome" >

     

     

     

    <ItemTemplate>

     

     

     

    <asp:Label ID="lblWelcome" runat="server" TabIndex="-1"></asp:Label>

     

     

     

    <table style="width: 100%">

     

     

     

    <tr>

     

     

     

    <td colspan="2" align="right">

     

     

     

    <table border="0" cellpadding="0" cellspacing="0" class="tbl_button">

     

     

     

    <tr>

     

     

     

    <td>

     

     

     

    <asp:Button ID="BtnNext" runat="server" OnClick="BtnNext_Click" Text="Next"

     

     

     

    CssClass="btn" />

     

     

     

    </td>

     

     

     

    </tr>

     

     

     

    </table>

     

     

     

    </td>

     

     

     

    </tr>

     

     

     

    </table>

     

     

     

    </ItemTemplate>

     

     

     

    </telerik:RadPanelItem>

     

     

     

    </Items>

     

     

     

    </telerik:RadPanelItem>

    </

     

    telerik:RadAjaxPanel>

     

     

     

     

     

    Thanks,
    Bharath

  6. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 30 Oct 2009 Link to this post

    Hi Bharathwajan Venkatanarayanan,

    You can easily focus the needed control on the client, i.e.

    <script type="text/javascript"
           function pageLoad() { 
               var txtBox = $get('<%= ((TextBox)RadPanelBar1.FindItemByValue("templateHolder").FindControl("CtlTextBox")).ClientID %>'); 
               txtBox.focus(); 
           }         
       </script>


    All the best,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Bharathwajan Venkatanarayanan
    Bharathwajan Venkatanarayanan avatar
    25 posts
    Member since:
    Aug 2009

    Posted 30 Oct 2009 Link to this post

    Hi paul,

    Thanks  a lot.it is working .....:)

    Regards,
    Bharath
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017