Captcha always validates

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
9/7/2011 11:38:20 AM
Gravatar
Total Posts 22

Captcha always validates

Hi,

Im just trying to use a Captcha on a custom module for the first time. The form is on a supporting page and after I submit the form I validate the page using Page.Validate() and then check if(page.Isvalid) do something.

However the problem I am having is regardless of what is entered for the Captcha, Page.Validate always returns true. I have configured the captcha as shown in the vid  but must be missing something as the captcha obviously isn't been validated with the page.

Captcha control on .aspx page

<mp:CaptchaControl ID="captcha" runat="server" />

Captcha set up in load settings

captcha.ProviderName = siteSettings.CaptchaProvider;
captcha.Captcha.ControlID = "captcha" + moduleId.ToInvariantString();
captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;

Button click event

protected void btnSubmitReview_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid) { return; }//Never returns here as page.IsValid is always true
            .

            .
            WebUtils.SetupRedirect(this, Request.RawUrl);
           
        }

Any help would be greatly appreciated

9/7/2011 11:49:44 AM
Gravatar
Total Posts 18439

Re: Captcha always validates

I would initialize the captcha settings from the OnInit event instead of page load (or call your LoadSettings from OnInit instead of page load).

If Page.IsValid is always returning true I would check also if(captcha.IsValid)

Hope that helps,

Joe

9/7/2011 3:15:09 PM
Gravatar
Total Posts 22

Re: Captcha always validates

Thanks a mil for the quick response Joe. Initializing the settings for captcha in Onit worked a treat. Seems like the obvious thing to try now that its been pointed out to me but had stepped thru it a few times and hadn't spotted that. Suppose its easy when u know how. Thanks again Joe. U saved me a lot of time and heart ache.

Starting to get to grips with mojoportal now and I have to say congrats its a great product.

You must sign in to post in the forums. This thread is closed to new posts.