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

Focus on text input

3 Answers 120 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
Kamil Zmeskal
Top achievements
Rank 1
Kamil Zmeskal asked on 16 Jun 2010, 02:38 PM
Hi,
I have a problem - how can I programable set focus on CAPTCHA textbox? I have tried this:
radCaptcha.FindControl("CaptchaTextBox").Focus();
and this:
Page.Form.DefaultFocus = radCaptcha.FindControl("CaptchaTextBox").ClientID; 
but I wan's success.
Kamil

3 Answers, 1 is accepted

Sort by
0
Kamil Zmeskal
Top achievements
Rank 1
answered on 16 Jun 2010, 02:52 PM
Hm, now
radCaptcha.FindControl("CaptchaTextBox").Focus(); 
works. I don't understand....
0
Accepted
Pero
Telerik team
answered on 18 Jun 2010, 08:20 AM
Hello Kamil,

You could also use client code to set the focus on the Captcha textbox. Here is simple code that sets the focus on Sys.Application.load:

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
 
    <script type="text/javascript">
        function pageLoad()
        {
            window.setTimeout(function()
            {
                var txtCaptcha = $get("<%=RadCaptcha1.ClientID %>" + "_CaptchaTextBox");
                txtCaptcha.focus();
            }, 10);
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </asp:ScriptManager>
    <div>
        <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Please enter the code shown correctly."
            CaptchaTextBoxLabel="ENTER CODE" EnableRefreshImage="true" CssClass="testClass"
            ForeColor="Brown">
            <CaptchaImage EnableCaptchaAudio="true" UseAudioFiles="true" />
        </telerik:RadCaptcha>
        <asp:Button ID="Button1" runat="server" Text="Verify Code" />
    </div>
    </form>
</body>
</html>


Regards,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kamil Zmeskal
Top achievements
Rank 1
answered on 18 Jun 2010, 08:22 AM
Hi Pero,
Thak you for quick response!
Kamil
Tags
Captcha
Asked by
Kamil Zmeskal
Top achievements
Rank 1
Answers by
Kamil Zmeskal
Top achievements
Rank 1
Pero
Telerik team
Share this question
or