Carrotware.Web.UI.Components.CaptchaImage.Validate C# (CSharp) Метод

Validate() публичный статический Метод

public static Validate ( string testValue ) : bool
testValue string
Результат bool
        public static bool Validate(string testValue)
        {
            if (String.IsNullOrEmpty(testValue)) {
                return false;
            }

            bool bValid = false;
            string guid = SessionKeyValue;

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

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

Usage 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);
        }