Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Captcha / Localization

Choose Language:







  • Localize Captcha

    RadCaptcha provides a mechanism for quick and easy localization, based on the native ASP.NET 2.0 localization. The ErrorMessage, the Label telling the user to enter the code, the button labels, all of these are obtained from the resource files located in the App_LocalReources directory, so that the language of the Captcha is automatically switched to the culture and UI culture of the Web page. The example uses the approach described in this Microsoft help article to programmatically change the culture and UI culture of an ASP.NET Web page.

    Each of the localization strings can be modified at runtime using the respective properties of the RadCaptcha control: ErrorMessage, CaptchaTextBoxLabel, CaptchaAudioLinkButtonText, and CaptchaLinkButtonText. This saves the need to create a new localization file to change a single string.



Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="C#" CodeFile="DefaultCS.aspx.cs" Inherits="Telerik.Web.Examples.Captcha.Localization.DefaultCS"
        Culture="auto" UICulture="auto" %>

    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <%@ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server"></qsf:HeadTag>
        <style type="text/css">
            .rcLabelClass
            {
                position: relative;
                top: -95px;
                left: -180px;
                color: White !important;
            }
            .rcTextBoxClass
            {
                width: 175px;
            }
            .divContainer
            {
                background: url('img/captchaBgr.png') no-repeat;
                width: 880px;
                height: 252px;
                position: relative;
                margin-top: 40px;
            }
            .rcCaptchaAudioLink
            {
                display: block;
                position: absolute;
                top: 110px;
                height: 22px;
                width: 96px;
                background: url('img/audioButton.png') no-repeat;
                font-size: 12px;
                line-height: 22px;
                text-decoration: none;
                padding-left: 25px;
                color: Black;
            }
            .rcRefreshImage
            {
                position: absolute;
                display: block;
                top: 110px;
                left: 140px;
                width: 25px;
                height: 22px;
                background: url('img/reloadButton.png') no-repeat;
            }
            .divLanguage
            {
                height: 100px;
                position: absolute;
                top: 50px;
                left: 100px;
            }
            .RadCaptcha
            {
                position: absolute;
                top: 70px;
                left: 300px;
            }
            .divButton
            {
                position: absolute;
                top: 100px;
                left: 575px;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" ShowSkinChooser="false" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="ajaxManager" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rblLanguages">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadCaptcha1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All"
            Skin="Simple" />
        <div class="divContainer">
            <div class="divLanguage">
    <asp:Label ID="lblChooseLanguage" runat="server" Text="Choose Language:" ForeColor="White"
    Style="line-height: 25px;" meta:resourcekey="Label1Resource1"></asp:Label><br />

                <asp:ListBox ID="chooseLanguage" runat="server" AutoPostBack="true" Width="100px">
                    <asp:ListItem Text="English" Value="en-US" Selected="True"></asp:ListItem>
                    <asp:ListItem Text="Francais" Value="fr-FR"></asp:ListItem>
                    <asp:ListItem Text="Deutsch" Value="de-DE"></asp:ListItem>
                </asp:ListBox>
            </div>
            <telerik:RadCaptcha ID="RadCaptcha1" runat="server" EnableRefreshImage="true" Display="None"
                Width="400px" ErrorMessage="Page not valid!" CaptchaTextBoxLabelCssClass="rcLabelClass"
                CaptchaTextBoxCssClass="rcTextBoxClass" CaptchaLinkButtonText="" meta:resourcekey="RadCaptcha1Resource1">
                <CaptchaImage EnableCaptchaAudio="true" UseAudioFiles="true" TextChars="Numbers"
                    TextColor="#cadada" BackgroundColor="#3f4f4f" />
            </telerik:RadCaptcha>
            <div class="divButton">
                <asp:Label ID="lblErrorMessage" runat="server" ForeColor="White"></asp:Label>
                <br />
                <br />
    <asp:Button ID="Button1" runat="server" Text="Submit Page" Width="200px" OnClick="Button1_Click"
    meta:resourcekey="Button1Resource1" />

            </div>
        </div>
        <br />
        <br />
        <br />
        <qsf:Footer runat="server" ID="Footer1" ShowCodeViewer="true" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451