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

how to load new captcha image from javascripts

1 Answer 295 Views
Captcha
This is a migrated thread and some comments may be shown as answers.
sai nsrs
Top achievements
Rank 1
sai nsrs asked on 06 Sep 2011, 05:31 AM
HI, Can you please tell me , how to reload new captcha image from javascript when ever client side validation of other controls fails in the same page.

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 08 Sep 2011, 04:11 PM
Hi Sai,

This can be easily achieved with a bit of JS code. Note that you must enable the refresh image functionality.
Here is a sample code that refreshes the image on a button click:
<%@ 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>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <script type="text/javascript">
        function RefreshImage()
        {
            var captcha = $find("<%=RadCaptcha1.ClientID %>");
            document.location = $get(captcha.get_id() + "_CaptchaLinkButton").href;
        }
    </script>
    <div>
        <input type="button" onclick="RefreshImage(); return false;" value="RefreshImage" />
        <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Invalid Code" ValidationGroup="Group"
            EnableRefreshImage="true" Width="400px" ForeColor="Red">
        </telerik:RadCaptcha>
        <asp:Button ID="Button1" runat="server" Text="Validate Code" ValidationGroup="Group" />
    </div>
    </form>
</body>
</html>

Greetings,
Pero
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Captcha
Asked by
sai nsrs
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or