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

Using CAPTCHA with asp.net login control

1 Answer 107 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 26 Jul 2012, 02:34 PM
Hello,
Is there any code samples available for using the CAPTCHA control with the .net login control?

Thank you,

1 Answer, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 31 Jul 2012, 01:32 PM
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">
    <LayoutTemplate>
        <span class="failureNotification">
            <asp:Literal ID="FailureText" runat="server"></asp:Literal>
        </span>
        <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
            ValidationGroup="LoginUserValidationGroup" />
        <div class="accountInfo">
            <fieldset class="login">
                <legend>Account Information</legend>
                <p>
                    <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."
                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                    <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."
                        ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
                </p>
                <p>
                <telerik:RadCaptcha runat="server" ID="RadCaptcha1" ErrorMessage="Wrong code!" ValidationGroup="LoginUserValidationGroup">
                </telerik:RadCaptcha>
                </p>
                <p>
                    <asp:CheckBox ID="RememberMe" runat="server" />
                    <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label>
                </p>
            </fieldset>
            <p class="submitButton">
                <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" />
            </p>
        </div>
    </LayoutTemplate>
</asp:Login>

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">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>


Kind regards,
Slav
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.
Tags
Documentation and Tutorials
Asked by
Tracy
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or