protected void OnNext(Object Sender, EventArgs args)
        {
            txtRegistrationCode.Text = txtRegistrationCode.Text.Trim();

            AvtRegistrationCode regCode;
            try {
                regCode = new AvtRegistrationCode(txtRegistrationCode.Text);
                //if (!regCode.IsValid(RedirectController.Version)) {
                //    throw new Exception();
                //}
            } catch {
                validateActivation.Text = "The registration code you supplied is invalid.";
                validateActivation.IsValid = false;
                return;
            }

            pnlHosts.Visible = true;

            //trDomains.Visible = true;
            ////ScriptManager.RegisterStartupScript(this, this.GetType(), "init1", "alert('" + regCode.ProductCode + "');", true);

            switch (regCode.VariantCode) {
                case "DOM":
                    FillHosts();
                    break;
                case "XDOM":
                    FillHosts();
                    break;
                case "SRV":
                    FillDomains();
                    break;
                case "30DAY":
                    FillAll();
                    break;
            }

            //btnActivate.Visible = true;
            btnNext.Visible = false;
            ////txtRegistrationCode.ReadOnly = true;
        }
        public AvtActivation Activate(string regCode, string productCode, string version, string host, string productKey)
        {
            AvtRegistrationCode r = new AvtRegistrationCode(regCode);

            // remove www
            if (host.IndexOf("www.") == 0 || host.IndexOf("http://www.") == 0 || host.IndexOf("https://www.") == 0) host = host.Substring(host.IndexOf("www.") + 4);

            // for domain license, also remove dev. and staging. (we grant these free)
            if (r.VariantCode == "DOM") {
                if (host.IndexOf("dev.") == 0 || host.IndexOf("http://dev.") == 0 || host.IndexOf("https://dev.") == 0) host = host.Substring(host.IndexOf("dev.") + 4);
                if (host.IndexOf("staging.") == 0 || host.IndexOf("http://staging.") == 0 || host.IndexOf("https://staging.") == 0) host = host.Substring(host.IndexOf("staging.") + 8);
            }

            Dictionary<string, string> data = new Dictionary<string, string>();
            Dictionary<string, string> prvData = new Dictionary<string, string>();
            data["product"] = productCode; // this is not encrypted because we need to extract the private key on the server side
            prvData["regcode"] = regCode;
            prvData["version"] = version;
            prvData["hostname"] = host;

            XmlDocument xmlAct = new XmlDocument();
            try {
                xmlAct.LoadXml(SendData(_regCoreSrv + "?cmd=activate", productKey, data, prvData));
            } catch (Exception e) {
                throw new Exception("An error occured (" + e.Message + ")");
            }

            if (xmlAct["error"] != null) {
                throw new Exception(xmlAct["error"].InnerText);
            }

            AvtActivation act = new AvtActivation();
            act.RegistrationCode = regCode;
            act.Host = xmlAct.FirstChild["host"].InnerText;
            act.ActivationCode = xmlAct.FirstChild["activation_code"].InnerText;
            act.ProductKey = xmlAct.FirstChild["product_key"].InnerText;
            act.BaseProductCode = r.ProductCode;
            act.BaseProductVersion = xmlAct.FirstChild["version"].InnerText;

            if (!act.IsValid(productCode, version)) {
                throw new Exception("Invalid activation");
            }

            // add activation
            _src.AddActivation(act);
            _initActivations[act.Host] = act;
            _validActivations[act.Host] = act;

            return act;
        }