Carrotware.Web.UI.Controls.CaptchaImage.Validate C# (CSharp) Method

Validate() public static method

public static Validate ( string TestValue ) : bool
TestValue string
return bool
        public static bool Validate(string TestValue)
        {
            bool bValid = false;
            string guid = GetKey();

            if (TestValue.ToLowerInvariant() == guid.ToLowerInvariant()) {
                bValid = true;
            }

            if (HttpContext.Current != null) {
                guid = Guid.NewGuid().ToString().Substring(0, 6);
                HttpContext.Current.Session["captcha_key"] = guid;
            }
            return bValid;
        }

Usage Example

Example #1
0
        public bool Validate()
        {
            this.IsValid = CaptchaImage.Validate(this.CaptchaText);

            if (!this.IsValid)
            {
                this.ValidationMessage = this.IsNotValidMessage;
            }
            else
            {
                this.ValidationMessage = this.IsValidMessage;
            }

            return(this.IsValid);
        }