This is a migrated thread and some comments may be shown as answers.

form defaultfocus does not work with telerik textbox

2 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Bridge24
Top achievements
Rank 1
Iron
Bridge24 asked on 04 Feb 2009, 04:09 PM
I recently changed all my asp:textbox for telerik:textbox. I just found that all my defaultfocus are not working.  

So I did a very simple test (code below) and found that it is really a telerik bug I think, when I set the defaultfocus on textbox1 or 2, it work (asp:textbox) but when I set it on textbox3 (telerik textbox), the focus do not go on the textbox3.  It reacts like if there were no defaultfocus property set.

<form id="form1" runat="server" defaultfocus="textbox2"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
    <asp:TextBox runat="server" ID="textbox1" Text="textbox1" /><br
    <asp:TextBox runat="server" ID="textbox2" Text="textbox2" /><br
    <telerik:RadTextBox ID="textbox3" runat="server" Text="textbox3" /> 
</form> 
 
 

Am I doing something wrong ?


2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 05 Feb 2009, 11:30 AM
Hi Dani,

RadTextBox consists of several <input /> elements and the visible one has a different Client ID. This is needed by the control's behavior and features.

You can set the defaultfocus like this:

C#

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Form.DefaultFocus = String.Format("{0}_text", RadTextBox1.ClientID);
       //  OR
        RadTextBox1.Focus();
    }


Best wishes,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bridge24
Top achievements
Rank 1
Iron
answered on 05 Feb 2009, 02:09 PM
Shame on me!  I should have done a little "view source" to see the textbox_text client id!

It works fine now, thank you.
Tags
General Discussions
Asked by
Bridge24
Top achievements
Rank 1
Iron
Answers by
Dimo
Telerik team
Bridge24
Top achievements
Rank 1
Iron
Share this question
or