Thanks for responding.
8 Answers, 1 is accepted
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
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.
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
<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>
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
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.
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
Hi Slav,
Yes, call the function with OnClientLoad works llike a charm. The usually grayed out image is now automatically refreshed.
Thank you.
An