Validation in ASP.NET when using a Custom Theme

199 views
Skip to first unread message

Cranial Entropy

unread,
Nov 25, 2009, 7:46:16 AM11/25/09
to reCAPTCHA
Hi all,

I have been using reCAPTCHA for a while and it has been working fine.
Today I decided to try out the custom theme option. Following the wiki
documentation I have a custom theme created but my project fails to
compile as there is no reCAPTCHA server control to validate against.
Previously, the .aspx page contained this:

<td colspan="2" align="center">
<div>
<recaptcha:RecaptchaControl
ID="recaptcha"
runat="server"
theme="clean"
PublicKey="6LdbmgkAAAAAADmWE2GlWPxNkAoWxWybMF-aQ33v"
PrivateKey="6LdbmgkAAAAAABOeCgsXhsrHYPlItWjjsrQutgn6"
/>
</div>
<asp:CustomValidator id="customValidator" runat="server"
onservervalidate="customValidator_ServerValidate" />
</td>

Now it looks like this:

<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol"
style="color:red">Incorrect please try again</div>

<span class="recaptcha_only_if_image">Enter the words above:</span>
<span class="recaptcha_only_if_audio">Enter the numbers you hear:</
span>

<input type="text" id="recaptcha_response_field"
name="recaptcha_response_field" />

<div><a href="javascript:Recaptcha.reload()">Get another CAPTCHA</a></
div>
<div class="recaptcha_only_if_image"><a
href="javascript:Recaptcha.switch_type('audio')">Get an audio CAPTCHA</
a></div>
<div class="recaptcha_only_if_audio"><a
href="javascript:Recaptcha.switch_type('image')">Get an image CAPTCHA</
a></div>

<div><a href="javascript:Recaptcha.showhelp()">Help</a></div>

<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=<Public Key>">
</script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=<Public Key>"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
</div>
So, how do I trigger the reCAPTCHA validation when using a custom
theme? Do I need to do it in Javascript or something?

Cranial Entropy

unread,
Nov 25, 2009, 11:38:18 AM11/25/09
to reCAPTCHA
Happily I found a solution to this issue. The key is to use the
WebRequest class (http://msdn.microsoft.com/en-us/library/
system.net.webrequest.aspx)
There is a very helpful blog post here http://nunos.zi-yu.com/2008/04/recaptcha-part-2/
on this subject too.
Reply all
Reply to author
Forward
0 new messages