RadCaptcha does not show image

9 posts, 0 answers
  1. An
    An avatar
    23 posts
    Member since:
    Aug 2013

    Posted 02 Aug 2013 Link to this post

    I am using Radcaptcha on my Login page and it is showing the image ok.  However, when I clicked on any button on my page, the image no longer appear.  I enabled the refresh linkbutton but this is not very user-friendly.  Is it possible that I programmatically refresh the image on OnLoad event so the image will be displayed every time?

    Thanks for responding.
  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 05 Aug 2013 Link to this post

    Hello,

    Please try the following


    1) Set the “EnableRefreshImage” property of rad captcha to true

    2) 
    Hook the “OnClientLoad” event in javascript and a call the below javascript function
    <script type="text/javascript">
           function GenerateNewImage() {
               var objradcaptcha = $find("<%=RadCaptcha1.ClientID %>");
               document.location = $get(objradcaptcha.get_id() + "_CaptchaLinkButton").href;
           }
       </script>


    Thanks,
    A2H
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. An
    An avatar
    23 posts
    Member since:
    Aug 2013

    Posted 06 Aug 2013 Link to this post

    I would get this error if call the javascript function.

    Webpage error details

    Message: 'null' is null or not an object
    Line: 198
    Char: 9
    Code: 0
     
    I have the radcaptcha and the javascript below in a separate .ascx file, loaded into the .aspx. 

    Thanks.

  5. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 06 Aug 2013 Link to this post

    Hi,

    I am afraid system will get the object of radcaptcha at runtime if you place the radcaptcha and javascript function in different pages.

    Please add the javascript function in the same ascx page where RadCapthca exists.

    Thanks,
    A2H

  6. An
    An avatar
    23 posts
    Member since:
    Aug 2013

    Posted 06 Aug 2013 Link to this post

    Sorry for the confusion.  I do put the javascript and the radcaptcha object in the same .ascx file.  This file is called by the .aspx page.  The null error occurs when I trigger GenerateNewImage(). 


     

    <script type="text/javascript">
        function GenerateNewImage() {
            var objradcaptcha = $find("<%=RadCaptcha1.ClientID %>");
            document.location = $get(objradcaptcha.get_id() + "_CaptchaLinkButton").href;
        }

    </script>

    <div style="width: 400px;">
            <telerik:RadCaptcha ID="RadCaptcha1" runat="server" ErrorMessage="Please enter the code below." EnableRefreshImage="true" RegisterWithScriptManager="true"
                ValidationGroup="Group" CaptchaTextBoxLabel="Type the code above" Font-Size="8pt">
            </telerik:RadCaptcha>
    </div>


  7. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 06 Aug 2013 Link to this post

    Hello,
    Please modify the javascript code like given below

    <script type="text/javascript">
            function GenerateNewImage() {
                var $ = $telerik.$;
                var objradcaptcha = $find("<%=RadCaptcha1.ClientID %>");
                document.location = $get(objradcaptcha.get_id() + "_CaptchaLinkButton").href;
            }
        </script>


    Thanks,
    A2H
  8. An
    An avatar
    23 posts
    Member since:
    Aug 2013

    Posted 14 Aug 2013 Link to this post

    A2H,

    I still got a Javascript error when trying to activate the link button automatically.  The clientID returned is still null, therefore, gave an exception on the browser.

    Thanks.
  9. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 16 Aug 2013 Link to this post

    Hi An,

    It is possible that the client-side object of the RadCaptcha is still not initialized when you invoke GenerateNewImage. Please verify that you are calling the function on the client-side event OnClientLoad of the captcha, on Sys.Application.load or after these events.

    Nevertheless, this is a workaround that may not remove the problem entirely. Please clarify whether a gray image appears or there is no image at all when the problem occurs.
     - If the image is grey, please check this help article on the matter.
     - In case the image just disappears, please provide a more detailed description of your setup and the steps for recreating the problem so that I can inspect it locally.

    Regards,
    Slav
    Telerik
    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 the blog feed now.
  10. An
    An avatar
    23 posts
    Member since:
    Aug 2013

    Posted 16 Aug 2013 Link to this post

    Hi Slav,

     

    Yes, call the function with OnClientLoad  works llike a charm.  The usually grayed out image is now automatically refreshed.

     

    Thank you.

    An

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017