// Register button in register view[1] of mvMain.
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            hideAllPlaceholders();

            using (DatabaseDataContext con = new DatabaseDataContext()) {
                #region checks

                // Checking if user has clicked on captcha
                string EncodedResponse = Request.Form["g-Recaptcha-Response"];
                bool   IsCaptchaValid  = (ReCaptcha.Validate(EncodedResponse) == "true" ? true : false);

                if (!IsCaptchaValid)
                {
                    showError("Prove that you are not a robot!", 1);
                    return;
                }

                // Checks for existing records with the same Email and Phonenumber
                if (con.tblUsers.Where(x => x.UserEmail.Equals(txtEmail.Text)).FirstOrDefault() != null)
                {
                    showError("A user with this email already exists!", 1);
                    return;
                }
                else if (con.tblUsers.Where(x => x.UserContact.Equals(txtContact.Text)).FirstOrDefault() != null)
                {
                    showError("A user with this Phone number already exists!", 1);
                    return;
                }

                // Checking the lenghts of inputs
                if (txtPassword.Text.Length > 15)
                {
                    showError("Password size is too large!", 1);
                    return;
                }
                else if (txtContact.Text.Length > 15)
                {
                    showError("Enter a valid Phone number!", 1);
                    return;
                }

                // Checking if there is a proof file or not.
                if (!imgProof.HasFile)
                {
                    showError("No proof file found!", 1);
                    return;
                }

                // Checking if the proof is a .jpg or .png image.
                if (!Utilities.isImage(Path.GetExtension(imgProof.FileName)))
                {
                    showError("Proof is not an image!", 1);
                    return;
                }

                // Checking if any of the textboxes are empty
                if (string.IsNullOrEmpty(txtFName.Text) || string.IsNullOrEmpty(txtLName.Text) ||
                    string.IsNullOrEmpty(txtContact.Text) || string.IsNullOrEmpty(txtEmail.Text) ||
                    string.IsNullOrEmpty(txtPassword.Text) || string.IsNullOrEmpty(txtAddress.Text))
                {
                    showError("Fill in all textboxes!", 1);
                    return;
                }

                #endregion

                tblUser user = new tblUser {
                    UserFName       = txtFName.Text,
                    UserLName       = txtLName.Text,
                    UserEmail       = txtEmail.Text,
                    UserPassword    = SecurityManager.encrypt(txtPassword.Text, txtEmail.Text),
                    UserContact     = txtContact.Text,
                    UserAddress     = txtAddress.Text,
                    UserRegDateTime = DateTime.UtcNow,
                    UserTypeID      = Convert.ToInt32(ddlUserType.SelectedValue),
                    UserProof       = txtContact.Text + Path.GetExtension(imgProof.FileName),
                    IsVerified      = false,
                    IsVisible       = true
                };

                try {
                    // Default save path of the image.
                    string savePath = Server.MapPath("~/Forms/Proof");

                    // Specify the path with saved file name.
                    string imgPath = Path.Combine(savePath, user.UserProof);

                    // Actually saving the proof image on server after the object has been successfully submitted.
                    imgProof.SaveAs(imgPath);

                    // Saving the object of the user.
                    con.tblUsers.InsertOnSubmit(user);
                    con.SubmitChanges();
                } catch (Exception ex) {
                    showError("Error: " + ex, 1);
                }

                // If user has been created, show success message.
                showSuccess("User " + txtFName.Text + "'s registration has been submitted! <a href=\"LoginRegister.aspx\">Click Here</a> to go to login page", 1);

                NotificationManager.requestSent();

                Utilities.clearAllTextBoxes(viewRegister);
            }
        }