protected void btnHiddenNext_onClick(object sender, EventArgs e)
    {
        StepOperation = 1;
        StepIndex++;

        switch (wzdInstaller.ActiveStepIndex)
        {
        case 0:
            // Set the authentication type
            AuthenticationType = userServer.WindowsAuthenticationChecked ? SQLServerAuthenticationModeEnum.WindowsAuthentication : SQLServerAuthenticationModeEnum.SQLServerAuthentication;

            // Check the server name
            if (String.IsNullOrEmpty(userServer.ServerName))
            {
                HandleError(ResHelper.GetFileString("Install.ErrorServerEmpty"));
                return;
            }

            // Do not allow to use empty user name or password
            bool isSQLAuthentication = AuthenticationType == SQLServerAuthenticationModeEnum.SQLServerAuthentication;
            if (isSQLAuthentication && (String.IsNullOrEmpty(userServer.DBUsername) || String.IsNullOrEmpty(userServer.DBPassword)))
            {
                HandleError(ResHelper.GetFileString("Install.ErrorUserNamePasswordEmpty"));
                return;
            }

            Password = userServer.DBPassword;

            // Check if it is possible to connect to the database
            string res = ConnectionHelper.TestConnection(AuthenticationType, userServer.ServerName, String.Empty, userServer.DBUsername, Password);
            if (!String.IsNullOrEmpty(res))
            {
                HandleError(res, "Install.ErrorSqlTroubleshoot", HELP_TOPIC_SQL_ERROR_LINK);
                return;
            }

            // Set credentials for the next step
            databaseDialog.AuthenticationType = AuthenticationType;
            databaseDialog.Password           = Password;
            databaseDialog.Username           = userServer.DBUsername;
            databaseDialog.ServerName         = userServer.ServerName;

            // Move to the next step
            wzdInstaller.ActiveStepIndex = 1;
            break;

        case 1:
        case COLLATION_DIALOG_INDEX:
            // Get database name
            Database = TextHelper.LimitLength(databaseDialog.CreateNewChecked ? databaseDialog.NewDatabaseName : databaseDialog.ExistingDatabaseName, 100);

            if (String.IsNullOrEmpty(Database))
            {
                HandleError(ResHelper.GetFileString("Install.ErrorDBNameEmpty"));
                return;
            }

            // Set up the connection string
            if (ConnectionHelper.IsConnectionStringInitialized)
            {
                ConnectionString = ConnectionHelper.ConnectionString;
            }
            else
            {
                ConnectionString = ConnectionHelper.BuildConnectionString(AuthenticationType, userServer.ServerName, Database, userServer.DBUsername, Password, SqlInstallationHelper.DB_CONNECTION_TIMEOUT);
            }

            // Check if existing DB has the same version as currently installed CMS
            if (databaseDialog.UseExistingChecked && !databaseDialog.CreateDatabaseObjects)
            {
                string dbVersion = null;
                try
                {
                    dbVersion = SqlInstallationHelper.GetDatabaseVersion(ConnectionString);
                }
                catch
                {
                }

                if (String.IsNullOrEmpty(dbVersion))
                {
                    // Unable to get DB version => DB objects missing
                    HandleError(ResHelper.GetFileString("Install.DBObjectsMissing"));
                    return;
                }

                if (dbVersion != CMSVersion.MainVersion)
                {
                    // Get wrong version number
                    HandleError(ResHelper.GetFileString("Install.WrongDBVersion"));
                    return;
                }
            }

            Info.LogContext = ctlAsyncDB.LogContext;

            // Use existing database
            if (databaseDialog.UseExistingChecked)
            {
                // Check if DB exists
                if (!DatabaseHelper.DatabaseExists(ConnectionString))
                {
                    HandleError(String.Format(ResHelper.GetFileString("Install.ErrorDatabseDoesntExist"), Database));
                    return;
                }

                // Get collation of existing DB
                string collation = DatabaseHelper.GetDatabaseCollation(ConnectionString);
                DatabaseHelper.DatabaseCollation = collation;

                if (wzdInstaller.ActiveStepIndex != COLLATION_DIALOG_INDEX)
                {
                    // Check target database collation and inform the user if it is not fully supported
                    if (!DatabaseHelper.IsSupportedDatabaseCollation(collation))
                    {
                        ucCollationDialog.IsSqlAzure = AzureHelper.IsSQLAzureServer(userServer.ServerName);
                        ucCollationDialog.Collation  = collation;
                        ucCollationDialog.InitControls();

                        // Move to "collation dialog" step
                        wzdInstaller.ActiveStepIndex = COLLATION_DIALOG_INDEX;
                        return;
                    }
                }
                else
                {
                    // Change database collation for regular database
                    if (ucCollationDialog.ChangeCollationRequested)
                    {
                        DatabaseHelper.ChangeDatabaseCollation(ConnectionString, Database, DatabaseHelper.DEFAULT_DB_COLLATION);
                    }
                }
            }
            else
            {
                // Create a new database
                if (!CreateDatabase(null))
                {
                    HandleError(String.Format(ResHelper.GetFileString("Install.ErrorCreateDB"), databaseDialog.NewDatabaseName));
                    return;
                }

                databaseDialog.ExistingDatabaseName = databaseDialog.NewDatabaseName;
                databaseDialog.CreateNewChecked     = false;
                databaseDialog.UseExistingChecked   = true;
            }

            if ((!SystemContext.IsRunningOnAzure && writePermissions) || ConnectionHelper.IsConnectionStringInitialized)
            {
                if (databaseDialog.CreateDatabaseObjects)
                {
                    if (DBInstalled && DBCreated)
                    {
                        ctlAsyncDB.RaiseFinished(this, EventArgs.Empty);
                    }
                    else
                    {
                        // Run SQL installation
                        RunSQLInstallation();
                    }
                }
                else
                {
                    CreateDBObjects = false;

                    // Set connection string
                    if (SettingsHelper.SetConnectionString(ConnectionHelper.ConnectionStringName, ConnectionString))
                    {
                        // Set the application connection string
                        SetAppConnectionString();

                        // Check if license key for current domain is present
                        LicenseKeyInfo lki = LicenseKeyInfoProvider.GetLicenseKeyInfo(hostName);
                        wzdInstaller.ActiveStepIndex = (lki == null) ? 4 : 5;
                        ucLicenseDialog.SetLicenseExpired();
                    }
                    else
                    {
                        ManualConnectionStringInsertion();
                    }
                }
            }
            else
            {
                ManualConnectionStringInsertion();
            }

            break;

        // After connection string save error
        case 2:
            // Check whether connection string is defined
            if (String.IsNullOrWhiteSpace(Service.Resolve <IConnectionStringService>()[ConnectionHelper.ConnectionStringName]))
            {
                HandleError(ResHelper.GetFileString("Install.ErrorAddConnString"));
                return;
            }

            ConnectionString = Service.Resolve <IConnectionStringService>()[ConnectionHelper.ConnectionStringName];

            if (CreateDBObjects)
            {
                if (DBInstalled)
                {
                    FinalizeDBInstallation();
                }
                else
                {
                    // Run SQL installation
                    RunSQLInstallation();
                }
            }
            else
            {
                // If this is installation to existing DB and objects are not created
                if ((hostName != "localhost") && (hostName != "127.0.0.1"))
                {
                    wzdInstaller.ActiveStepIndex = 4;
                }
                else
                {
                    wzdInstaller.ActiveStepIndex = 5;
                }
            }
            break;

        // After DB install
        case 3:
            break;

        // After license entering
        case 4:
            try
            {
                if (ucLicenseDialog.Visible)
                {
                    ucLicenseDialog.SetLicenseKey();
                    wzdInstaller.ActiveStepIndex = 5;
                }
                else if (ucWagDialog.ProcessRegistration(ConnectionString))
                {
                    wzdInstaller.ActiveStepIndex = 5;
                }
            }
            catch (Exception ex)
            {
                HandleError(ex.Message);
            }
            break;

        default:
            wzdInstaller.ActiveStepIndex++;
            break;
        }
    }