asp.net api using asp:multivew

102 views
Skip to first unread message

joeydeaks

unread,
Feb 17, 2009, 9:42:14 AM2/17/09
to reCAPTCHA
Hi

See

http://www.leedsinitiative.org/formTest.aspx

This is an implementation alongside a CMS product called ektron.

Forms are entered via the CMS by end users and the ektron product
renders them on screen in a form control.

They are getting bot rubbish trough. So I added reCaptcha.

To do it on this platform (without requiring users to do anything
different in their CMS) I put the captcha control in one view, then
the form in another view. You get the captcha right then you get the
form. OK so far.

However - when you submit the form you get an error ... an error wich
I need to ignore but I don't know how to.
It's weird because the error relates to reCaptcha - but recaptcha at
this point is no longer on the page as we have switched views.

The error is :

Value cannot be null
Parameter name: Challenge

joeydeaks

unread,
Feb 17, 2009, 11:05:34 AM2/17/09
to reCAPTCHA
mmm - more notes on this one ...

OK - I can set SkipRecaptcha to true once a valid response is
received.

But the form which is called after submitting a valid repsonse (in a
new view) uses an html submit button and when I press this button the
error comes up. Even though I set SkipRecaptcha to true once the
button was pressed to validate it.

If I could set SkipRecaptcha=false on this button click then I think
we'd be there.

Sooo - question is - how do I append an action to an html button
onClick that would set SkipCatcha to true

Adrian Godong

unread,
Feb 17, 2009, 11:35:57 AM2/17/09
to reca...@googlegroups.com
Quick Note:

SkipRecaptcha is not used for this situation. SkipRecaptcha is used
when you need to test the pages in your local enviroment (thus, not
requiring you to test the captcha).

The problem may arise from the ASP.NET. Multiviews are technically
single page, so that means the reCAPTCHA control is loaded somewhere
else. What if you do selective loading of reCAPTCHA control based on
current view?
--
Adrian Godong
adrian...@gmail.com
Microsoft MVP
https://mvp.support.microsoft.com/profile/Adrian

khemo

unread,
Mar 20, 2009, 10:13:38 PM3/20/09
to reCAPTCHA
How does one do "selective loading of reCAPTCHA control based on
current view"?
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian

Adrian Godong

unread,
Mar 21, 2009, 3:36:40 AM3/21/09
to reca...@googlegroups.com
Place the reCAPTCHA on one of the view, and then show or hide the view
based on the business logic.

khemo

unread,
Mar 21, 2009, 1:38:27 PM3/21/09
to reCAPTCHA
It already is on one view, and the default behavior of multiview &
view requires the show/hide of the view to move from one view to the
other, so it's already doing that and the issue still occurs.
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian

Adrian Godong

unread,
Mar 21, 2009, 2:42:05 PM3/21/09
to reca...@googlegroups.com
Sorry, I lost context for my previous e-mail. Ignore that for now.

So the problem right now is that reCAPTCHA is still doing validation
even though it's not on the active view? I never tried this scenario
before, so it may be the case. Let me try this and I'll get back to
you.

RincewindTVD

unread,
Mar 24, 2009, 11:51:15 PM3/24/09
to reCAPTCHA
I'm having a similar issue with using reCaptcha in a dotnet Wizard
Control (the wizard control is built on multiview I think)

it looks like I might have to edit the validate command to return true
if it's already been validated (as the wizard control validates it
every time any page is changed, not just the page the control is on).

that or find a way to add a validation group to it, that might fix my
issues.

-RtVD
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian

khemo

unread,
Mar 25, 2009, 9:37:32 PM3/25/09
to reCAPTCHA
Ditto validation group, that seems like the logical way to approach
the issue.

How long before an update/news on this?

I'm assuming everyone working on this has full time jobs elsewhere.
However, this page needs to be in code freeze by monday morning... any
chance of ValidationGroup or other fix ?

Adrian Godong

unread,
Mar 26, 2009, 7:56:01 AM3/26/09
to reca...@googlegroups.com
OK, since everyone's starting to voice up, I'm checking it right now.

1. I have repro on this problem. I've not yet hit the root cause yet,
logically if it's not placed in an active view, it shouldn't be loaded
at all. But yes, it was loaded and validated.
2. ValidationGroup way may not be easy. This is because we used
different inheritance hierarchy. ValidationGroup comes from
BaseValidator which implements IValidator. RecaptchaControl (the
control you dragged and dropped) just implements IValidator. If you
want this ValidationGroup, then we will need to change the hierarchy.
Easy, but lots of test need to be done.

I'm looking at possible fix now. Anyone with hints or patches voice up.

Adrian Godong

unread,
Mar 26, 2009, 8:06:53 AM3/26/09
to reca...@googlegroups.com
Since no one's commented, it's fixed now.

Please grab rev109 from svn.

khemo

unread,
Mar 27, 2009, 8:48:18 AM3/27/09
to reCAPTCHA
Sounds terriffic, thank you for all your time in making the change.

Where is the svn? Please forgive me, but it's been a long time since I
originally downloaded & installed reCAPTCHA.
> > adrian.god...@gmail.com
> > Microsoft MVP
> >https://mvp.support.microsoft.com/profile/Adrian
>
> --
> Adrian Godong
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian- Hide quoted text -
>
> - Show quoted text -

Adrian Godong

unread,
Mar 27, 2009, 8:51:14 AM3/27/09
to reca...@googlegroups.com
code.google.com search for recaptcha

khemo

unread,
Mar 27, 2009, 8:57:39 AM3/27/09
to reCAPTCHA
Been there, did that, didn't find it.

Found this, please confirm that is it:
http://code.google.com/p/recaptcha/source/browse/trunk/recaptcha-plugins/dotnet/library/

Also, please confirm: do I need to download all these files and build
it myself, or ....???


(Google groups & code are blocked from work, so for me to get here is
a big elbow twisting issue and takes a half hour to get access each
time. I'm grabbing all of it in case your reply to the above is yes. I
have a demo & status meeting by lunch time, and I'm really hoping I
can say "yes, we can use this great recaptcha AND we'll make the
timeframe.)
> >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hide quoted text -

Adrian Godong

unread,
Mar 27, 2009, 9:05:52 AM3/27/09
to reca...@googlegroups.com
You can download it and build it yourself, absolutely.

khemo

unread,
Mar 27, 2009, 9:11:36 AM3/27/09
to reCAPTCHA
Thank you so much for confirming!

It built successfully, so I'm logging off here and going to try the
new DLL with the project!

Thanks again!

On Mar 27, 9:05 am, Adrian Godong <adrian.god...@gmail.com> wrote:
> You can download it and build it yourself, absolutely.
>
>
>
>
>
> On Fri, Mar 27, 2009 at 12:57 PM, khemo <jen...@gmail.com> wrote:
>
> > Been there, did that, didn't find it.
>
> > Found this, please confirm that is it:
> >http://code.google.com/p/recaptcha/source/browse/trunk/recaptcha-plug...
> >> >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hidequoted text -

khemo

unread,
Mar 27, 2009, 10:20:47 AM3/27/09
to reCAPTCHA
* Ok, no errors with the new dll and no other changes.
* Moved recaptcha to the first view, Added ValidationGroup="Step1" to
the recaptcha and no effect: could skip it entirely and move to the
next view.
* Thought better of putting ValidationGroup within the recaptcha
control, so I added a RFV with ControlToValidate = the recaptcha id,
and ValidationGroup="Step1". To me it's a textbox, but possiblly .NET
doesn't see it as such. (see
http://www.velocityreviews.com/forums/t109657-quotcannot-be-validatedquot-why-not.html
and http://www.4guysfromrolla.com/articles/092006-1.aspx)

Questions:
* Can it inherit from texbox?
* Should I take a different approach for specifiying the
ValidationGroup?

Thanks.
> > >> >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hidequotedtext -
>
> > >> >> - Show quoted text -
>
> > >> --
> > >> Adrian Godong
> > >> adrian.god...@gmail.com
> > >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hidequoted text -
>
> > >> - Show quoted text -
>
> > --
> > Adrian Godong
> > adrian.god...@gmail.com
> > Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

khemo

unread,
Mar 27, 2009, 10:22:11 AM3/27/09
to reCAPTCHA
Here is the error I got with the RFV:
Server Error in '/TriWorld' Application.
Control 'recaptcha1' referenced by the ControlToValidate property of
'rfvrecaptcha1' cannot be validated.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Control 'recaptcha1'
referenced by the ControlToValidate property of 'rfvrecaptcha1' cannot
be validated.

Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace
below.


Stack Trace:

[HttpException (0x80004005): Control 'recaptcha1' referenced by the
ControlToValidate property of 'rfvrecaptcha1' cannot be validated.]

System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty
(String name, String propertyName) +8734357
System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid()
+40
System.Web.UI.WebControls.BaseValidator.get_PropertiesValid() +21
System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e)
+27
System.Web.UI.Control.PreRenderRecursiveInternal() +80
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Control.PreRenderRecursiveInternal() +171
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+842



Version Information: Microsoft .NET Framework Version:2.0.50727.3082;
ASP.NET Version:2.0.50727.3082

On Mar 27, 10:20 am, khemo <jen...@gmail.com> wrote:
> * Ok, no errors with the new dll and no other changes.
> * Moved recaptcha to the first view, Added ValidationGroup="Step1" to
> the recaptcha and no effect: could skip it entirely and move to the
> next view.
> * Thought better of putting ValidationGroup within the recaptcha
> control, so I added a RFV with ControlToValidate = the recaptcha id,
> and ValidationGroup="Step1". To me it's a textbox, but possiblly .NET
> doesn't see it as such. (seehttp://www.velocityreviews.com/forums/t109657-quotcannot-be-validated...

Adrian Godong

unread,
Mar 27, 2009, 10:31:38 AM3/27/09
to reca...@googlegroups.com
Err... no. It doesn't work that way.

reCAPTCHA itself is already a validator control. You can't validate a
validator control.

Plus, we're not using that ValidationGroup property, it comes from a
different hierarchy (told you that).

Just drop it on any view that needs it, that should work.

khemo

unread,
Mar 27, 2009, 10:18:46 PM3/27/09
to reCAPTCHA
Ok, if it can't use ValidationGroup, and it still uses the wrong
hierarchy, then what did you "fix"?

If it fails to validate when moving from the view it's on, then what's
your intent of "...that should work"? Just that it doesn't blow up the
whole page? Even though it never tells the user that they failed to
enter anything, nor does it say if they entered the wrong text?

In my testing it only alerts the user when it is on the last view.

On Mar 27, 10:31 am, Adrian Godong <adrian.god...@gmail.com> wrote:
> Err... no. It doesn't work that way.
>
> reCAPTCHA itself is already a validator control. You can't validate a
> validator control.
>
> Plus, we're not using that ValidationGroup property, it comes from a
> different hierarchy (told you that).
>
> Just drop it on any view that needs it, that should work.
>
>
>
> On Fri, Mar 27, 2009 at 2:20 PM, khemo <jen...@gmail.com> wrote:
>
> > * Ok, no errors with the new dll and no other changes.
> > * Moved recaptcha to the first view, Added ValidationGroup="Step1" to
> > the recaptcha and no effect: could skip it entirely and move to the
> > next view.
> > * Thought better of putting ValidationGroup within the recaptcha
> > control, so I added a RFV with ControlToValidate = the recaptcha id,
> > and ValidationGroup="Step1". To me it's a textbox, but possiblly .NET
> > doesn't see it as such. (see
> >http://www.velocityreviews.com/forums/t109657-quotcannot-be-validated...
> >> > - Show quoted text -- Hide quoted text -
>
> >> - Show quoted text -
>
> --
> Adrian Godong
> adrian.god...@gmail.com
> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian

Adrian Godong

unread,
Mar 28, 2009, 6:46:56 PM3/28/09
to reca...@googlegroups.com
Have you tried it yet?

It's not on the wrong hierarchy. "Fix" can be found by diff-ing last 2
version (of the only 2 version).

Susan Braddock

unread,
Apr 21, 2009, 7:25:32 PM4/21/09
to reCAPTCHA
Hi Adrian,

Having a similar problem myself, with the CAPTCHA on the last step of
a Wizard (works fine, unless the user goes back to a previous step), I
did a search on the forum and came to this thread.

My question is how to build your modified RecaptchaControl.cs into the
DLL myself - I'm using Visual Web Developer not Visual C# or the full
Visual studio and I'm not too hot on C#, I've just put the CAPTCHA in
a template field and I'm in the process of testing it locally at the
moment.

Please help.

Regards,

Susan


On Mar 27, 3:05 pm, Adrian Godong <adrian.god...@gmail.com> wrote:
> You can download it and build it yourself, absolutely.
>
>
>
> On Fri, Mar 27, 2009 at 12:57 PM, khemo <jen...@gmail.com> wrote:
>
> > Been there, did that, didn't find it.
>
> > Found this, please confirm that is it:
> >http://code.google.com/p/recaptcha/source/browse/trunk/recaptcha-plug...
> >> >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hidequoted text -

Susan Braddock

unread,
Apr 22, 2009, 12:36:00 PM4/22/09
to reCAPTCHA
Following on from my last message, I downloaded Visual C# Express and
rebuilt the DLL with the new RecaptchaControl.cs. However, now if the
user goes back to a previous step in the Wizard, they can no longer go
forward afterwards. So was the change really a fix for the error:

"Value cannot be null.
Parameter name: Challenge"

Regards,

Susan
> > >> >> Microsoft MVPhttps://mvp.support.microsoft.com/profile/Adrian-Hidequotedtext -

Adrian Godong

unread,
Apr 22, 2009, 12:42:09 PM4/22/09
to reca...@googlegroups.com
Debug and see why it is validating (I assume you don't want it to validate).
--
Adrian Godong
adrian...@gmail.com

Susan Braddock

unread,
Apr 22, 2009, 3:06:47 PM4/22/09
to reCAPTCHA
Hi,

IsValid was getting set to false without any validation being carried
out. I added the following lines to RecaptchaControl.cs, after line
213:

else
{
recaptchaResponse = RecaptchaResponse.Valid;
}

and it now works.

RincewindTVD

unread,
Apr 28, 2009, 10:30:51 PM4/28/09
to reCAPTCHA
Ok, it looks like I need some help here.

as mentioned above, I'm using the dotnet wizard control, and I'm
having issues with having the recaptcha on the last page of my wizard.
I've built recaptcha from the version listed above, with the else
statement suggested by Susan.

I'm having some odd issues.

I set the recaptcha visible as false until the wizard page where it's
supposed to be viewed (the third and penultimate page), and I'm
getting the recaptcha verification message on the first page of the
wizard.

Reaching the 3rd page of the wizard, clicking finish will run the
finish_button method before it validates the recaptcha control, this
is really weird because it processes the other validators on that
wizard page before the submission (as it should).

the other validators are just some regular expressions for checking
input data.

Should I be calling the validate() method manually before attempting
to process the finish button?

It seems odd that I would have to validate it manually. since this is
a validation control.


-RtVD
> ...
>
> read more »

drevange

unread,
Apr 29, 2009, 3:26:51 AM4/29/09
to reCAPTCHA
OK. This needs to be fixed and I am not sure how to proceed.

I am using asp:login control with a LayoutTemplate. It is a bit
redundant to have the captcha here but is good for testing purposes.

I should "not" be able to submit the login page if I have not entered
the captcha. There does "not" seem to be any validation at all prior
to submitting, as is the case on the username and password field. It
does not seem like I can add a validator as the RenderContents
(HtmlTextWriter output) seems to be just generating html so cannot
leverage a proper validator.

It will not actually login without a proper captcha entry but the
behavior is terrible. It submits and the page clears with no comment
about what happened. The username field is there, but the password is
cleared out and there is not comment form the captcha explaining what
happened.

I noticed in earlier comments about changing the hierarchy? Would
that fix this?

What can we do to make it "properly" validate?
> > read more »- Hide quoted text -

Adrian Godong

unread,
Apr 29, 2009, 4:47:08 AM4/29/09
to reca...@googlegroups.com
By design the IsValid property returns false if recaptchaResponse is not set.
--
Adrian Godong
adrian...@gmail.com

hostm...@enigmedia.com

unread,
Apr 29, 2009, 10:51:21 AM4/29/09
to reCAPTCHA


On Apr 29, 4:47 am, Adrian Godong <adrian.god...@gmail.com> wrote:
> By design the IsValid property returns false if recaptchaResponse is not set.

I'm experiencing the same issue as drevange, and I believe what he's
saying is the page is posting back even if the recaptcha challenge is
blank. When the page loads after the postback, page.isvalid is false
because recaptcha is false, but it should not have posted back in the
first place?
> ...
>
> read more »

Adrian Godong

unread,
Apr 29, 2009, 11:11:59 AM4/29/09
to reca...@googlegroups.com
I'm lost. Can you provide a step by step repro? If the problem was
postback, I already requested that information but no one seemed to
understand how to debug.
--
Adrian Godong
adrian...@gmail.com

hostm...@enigmedia.com

unread,
Apr 30, 2009, 9:26:00 AM4/30/09
to reCAPTCHA
Adrian: I apologize for interjecting into this thread. My issue is
unrelated to the controls except in the behavior I'm seeing...I'll
repost a separate thread.
Reply all
Reply to author
Forward
0 new messages