Validate MSCaptcha in asp.net using jQuery

Viewed 16

I am using MSCaptcha in my project. I will capture the FirstName, Lastname and other user parameters including MSCaptcha Text from the popup in my aspx page and make an ajax jQuery call to send the payload to the static WebMethod in the codeBehind and create the user.

In this, I am facing the issue in the MSCaptcha validation in the code behind C# as the ajax jQuery invokes static WebMethod in C# Codebehind and the Page controls are not accessible in static method.

Is there any way to validate the MSCaptcha in jQuery at Client-Side itself ?

I tried the below piece of code to read the PageControls inside the static WebMethod. But it didn't helped.

        bool resp = true;
        if (HttpContext.Current.Handler != null)
        {
            Page page = (Page)HttpContext.Current.Handler;
            MSCaptcha.CaptchaControl captcha = (MSCaptcha.CaptchaControl)page.FindControl("CaptchaControl1") as MSCaptcha.CaptchaControl;//.ValidateCaptcha(secCode);

            TextBox TextBox1 = (TextBox)page.FindControl("txtVerificationCode");

            captcha.ValidateCaptcha(TextBox1.text);
            resp = captcha.UserValidated;
        }
0 Answers
Related