Focus on text input

4 posts, 1 answers
  1. Kamil Zmeskal
    Kamil Zmeskal avatar
    16 posts
    Member since:
    Sep 2012

    Posted 16 Jun 2010 Link to this post

    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
  2. Kamil Zmeskal
    Kamil Zmeskal avatar
    16 posts
    Member since:
    Sep 2012

    Posted 16 Jun 2010 Link to this post

    Hm, now
    radCaptcha.FindControl("CaptchaTextBox").Focus(); 
    works. I don't understand....
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 18 Jun 2010 Link to this post

    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
  5. Kamil Zmeskal
    Kamil Zmeskal avatar
    16 posts
    Member since:
    Sep 2012

    Posted 18 Jun 2010 Link to this post

    Hi Pero,
    Thak you for quick response!
    Kamil
Back to Top