Using CAPTCHA with login control

2 posts, 1 answers
  1. Tracy
    Tracy avatar
    4 posts
    Member since:
    Jul 2012

    Posted 26 Jul 2012 Link to this post

    Is there any code samples available for using the CAPTCHA control with the .net login control?

    Thank you,
  2. Answer
    Slav avatar
    1359 posts

    Posted 31 Jul 2012 Link to this post

    Hello Tracy,

    The following code sample demonstrates the use of a RadChaptcha in a ASP Login control. As you can check its configuration is standard. Keep in mind that the value of its property LoginUserValidationGroup should match that of the other validated controls in order to include the RadCaptcha  in the ASP.NET validation.
    <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
            <span class="failureNotification">
                <asp:Literal ID="FailureText" runat="server"></asp:Literal>
            <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
                ValidationGroup="LoginUserValidationGroup" />
            <div class="accountInfo">
                <fieldset class="login">
                    <legend>Account Information</legend>
                        <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                        <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                            CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required."
                        <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                            CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required."
                    <telerik:RadCaptcha runat="server" ID="RadCaptcha1" ErrorMessage="Wrong code!" ValidationGroup="LoginUserValidationGroup">
                        <asp:CheckBox ID="RememberMe" runat="server" />
                        <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                <p class="submitButton">
                    <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" />

    Also, when using authentication it is recommended to allow access to the RadCaptcha HttpHandler to all users by adding the following code snippet in web.config:
    <location path="Telerik.Web.UI.WebResource.axd">
                <allow users="*"/>

    Kind regards,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top