Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Panelbar > Set focus on a Textbox inside a RadPanelBar on Page Load.
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered Set focus on a Textbox inside a RadPanelBar on Page Load.

Feed from this thread
  • Jessie avatar

    Posted on Aug 31, 2009 (permalink)

    How do I set the focus on a RadTextBox that's inside a RadPanelBar? I made a simple example below for reference. In this code, I want the focus to be on RadTextBox3 on Page load but it's not working as expected. Thanks.

    <form id="form1" runat="server"> 
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" > 
        </telerik:RadScriptManager> 
        <telerik:RadPanelBar ID="RadPanelBar1" runat="server" > 
            <Items> 
                <telerik:RadPanelItem runat="server" Text="Panel1" Expanded="True"> 
                 <Items> 
                    <telerik:RadPanelItem runat="server" Value="TemplateHolder"> 
                        <ItemTemplate> 
                            <telerik:RadTextBox ID="RadTextBox3" runat="server" FocusedStyle-BorderColor="red"> 
                            </telerik:RadTextBox> 
                            <telerik:RadTextBox ID="RadTextBox4" runat="server" FocusedStyle-BorderColor="red"> 
                            </telerik:RadTextBox> 
                        </ItemTemplate> 
                    </telerik:RadPanelItem> 
                 </Items> 
                </telerik:RadPanelItem> 
              <telerik:RadPanelItem runat="server" Text="Panel2"> 
              </telerik:RadPanelItem> 
            </Items> 
         </telerik:RadPanelBar>
    </form>   

     

    public partial class Test : System.Web.UI.Page

        RadTextBox textBox3; 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            textBox3 = (RadTextBox)RadPanelBar1.FindItemByText("Panel1").Items[0].FindControl("RadTextBox3"); 
            textBox3.Focus(); 
            //textBox3.Visible = false; // this works fine, for testing that I get the control RadTextBox3 
        }
    }

     

  • Atanas Korchev Atanas Korchev admin's avatar

    Posted on Sep 2, 2009 (permalink)

    Hello Jessie,

    I tested your code and everything worked fine with the current official release - Q2 2009 SP2. I am attaching my test page.

    Regards,
    Albert,
    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.
    Attached files

  • Posted on Jan 10, 2011 (permalink)

    I am using 2009.1.311.35 version and I am also facing the same focus problem, is it but in this version?


    See what happen with this example:

    There are two textbox in this example "RadTextBox3" and "RadTextBox4"

    In your code you focus on "RadTextBox3" in Page_Load event. Everything work correctly, it focus on "RadTextBox3" and also I able to write text in textbox but what happen now when I press Tab key suddenly my text disappear (clear) and also Tab not moved to next textbox but focused remain in the same textbox ("RadTextBox3").

    Here I attach steps to follow above process.

    It working fine if I change Default focus from "RadTextBox3" to "RadTextBox4" in Page Load event
    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Panelbar > Set focus on a Textbox inside a RadPanelBar on Page Load.