Пример #1
0
        private bool VerifyCaptchaText()
        {
            //To navigate to the ContentTemplate, use CreateUserWizard1.WizardSteps[0].Controls[0]
            Control ctrl = this.Master.FindControl("body1").FindControl("ctrlCaptcha");

            //I won't check for null. The page should work or the custom eror should catch it, so its fixed.
            //if (ctrl != null)
            Lanap.BotDetect.Captcha captchaControl = (Lanap.BotDetect.Captcha)ctrl;

            ctrl = this.Master.FindControl("body1").FindControl("CaptchaText");
            TextBox txtCaptchaText = (TextBox)ctrl;

            return(captchaControl.Validate(txtCaptchaText.Text.Trim()));
        }
Пример #2
0
        //protected void ctrlCaptcha_PreRender(object sender, EventArgs e)
        //{
        //    Lanap.BotDetect.Captcha captchaControl = (Lanap.BotDetect.Captcha)sender;
        //    StringBuilder sb = new StringBuilder();
        //    StringWriter tw = new StringWriter(sb);
        //    HtmlTextWriter hw = new HtmlTextWriter(tw);
        //    captchaControl.RenderControl(hw);
        //    tw.Flush();
        //    sb.Replace("this.blur();", "");
        //    captchaControl.Visible = false;

        //    string controlName = captchaControl.ID;

        //    Control c = TemplateControl.ParseControl(sb.ToString());
        //    this.Form.Controls.Remove(FindControl(controlName));
        //    this.Form.FindControl("Panel1").Controls.Add(c);

        //}


        private bool VerifyCaptchaText()
        {
            //To navigate to the ContentTemplate, use CreateUserWizard1.WizardSteps[0].Controls[0]
            Control ctrl = this.Master.FindControl("body1").FindControl("ctrlCaptcha");

            //I won't check for null. The page should work or the custom eror should catch it, so its fixed.
            //if (ctrl != null)
            Lanap.BotDetect.Captcha captchaControl = (Lanap.BotDetect.Captcha)ctrl;

            ctrl = this.Master.FindControl("body1").FindControl("CaptchaText");
            TextBox txtCaptchaText = (TextBox)ctrl;

            bool IsValid = captchaControl.Validate(txtCaptchaText.Text.Trim());

            //EnableViewState apparently doesnt work here. So, a fix to clear the previous captcha text.
            txtCaptchaText.Text = string.Empty;
            return(IsValid);
        }