App_Code.Controls.RecaptchaControl.OnInit C# (CSharp) Method

OnInit() protected method

Raises the E:System.Web.UI.Control.Init event.
protected OnInit ( EventArgs e ) : void
e System.EventArgs /// An object that contains the event data. ///
return void
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            var settings = ExtensionManager.GetSettings("Recaptcha");
            this.publicKey = settings.GetSingleValue("PublicKey");
            this.privateKey = settings.GetSingleValue("PrivateKey");

            if (String.IsNullOrEmpty(this.Theme))
            {
                this.Theme = settings.GetSingleValue("Theme");
            }

            if (String.IsNullOrEmpty(this.Language))
            {
                this.Language = settings.GetSingleValue("Language");
            }

            if (this.RecaptchaEnabled && this.RecaptchaNecessary)
            {
                this.skipRecaptcha = false;
            }

            if (String.IsNullOrEmpty(this.publicKey) || String.IsNullOrEmpty(this.privateKey))
            {
                throw new ApplicationException("reCAPTCHA needs to be configured with a public & private key.");
            }
        }