コード例 #1
0
    //Handles search button click
    public void SearchButton_Click(Object s, EventArgs e)
    {
        //Instantiate validation object
        Utility Util = new Utility();

        //Check for minimum keyword character
        int MinuiumSearchWordLength = 2;
        int SearchWordLength;
        SearchWordLength = find.Value.Length;
        if (SearchWordLength <= MinuiumSearchWordLength)
        {
            //Redirect to keyword too short page
            Util.PageRedirect(10);
        }

        if (this.SelectedValue != null)
        {
            SDropName.SelectedValue = this.SelectedValue;
        }

        string targetUrl = "searcharticle.aspx";

        targetUrl += "?find=" + Util.FormatTextForInput(find.Value) + "&catid=" + SDropName.SelectedValue;

        //Redirect to the search page
        Response.Redirect(targetUrl);

        Util = null;
    }
コード例 #2
0
    public void ProcessLogin(Object s, EventArgs e)
    {
        //Instantiate validation
        Utility Util = new Utility();

        string Username;
        string Userpass;

           #region Input Validations
        //Validate username and password both are empty.
        if (Request.Form["uname"].Trim() == "" && Request.Form["password"].Trim() == "")
        {
            lblerror.Text = "Hãy tài khoản người dùng và mật khẩu.";
            return;
        }
        if (Request.Form["uname"].Trim() == "")
        {
            lblerror.Text = "Hãy nhập tài khoản người dùng.";
            return;
        }
        if (Request.Form["password"].Trim() == "")
        {
            lblerror.Text = "Hãy nhập mật khẩu.";
            return;
        }
          #endregion

        //Retreive value from the request.form property and filter dirty character.
        Username = Util.FormatTextForInput(Request.Form["uname"]);
        Userpass = Util.FormatTextForInput(Request.Form["password"]);

        //Do final login process with validation
        ProcessLoginCheck(Username, Userpass);

        Util = null;
    }
コード例 #3
0
ファイル: addlyric.aspx.cs プロジェクト: mangmaytinh/vguitar
    public void Add_Recipe(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            if (Page.IsValid)
            {
                Utility Util = new Utility();

                LyricRepository lyric = new LyricRepository();

                //Filters harmful scripts from input string.
                lyric.LyricName = Util.FormatTextForInput(Request.Form[Name.UniqueID]);
                lyric.Author = Util.FormatTextForInput(Request.Form[Author.UniqueID]);
                lyric.CatID = int.Parse(Request.Form[CategoryID.UniqueID]);
                lyric.Ingredients = Util.FormatTextForInput(Request.Form[Ingredients.UniqueID]);
                lyric.Instructions = Util.FormatTextForInput(Request.Form[Instructions.UniqueID]);

                lyric.UID = UserIdentity.UserID;

                #region Form Input Validator
                //Validate for empty recipe name
                if (lyric.LyricName.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: lyric Name is empty, please enter a recipe name.";
                    lbvalenght.Visible = true;
                    return;
                }
                if (lyric.CatID == 0)
                {
                    lbvalenght.Text = "<br>Error: You must select a category where you want your recipe to show.";
                    lbvalenght.Visible = true;
                    return;
                }
                //Validate for empty author name
                if (lyric.Author.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: Author Name is empty, please enter the author name";
                    lbvalenght.Visible = true;
                    return;
                }
                //Validate for empty ingredients
                if (lyric.Ingredients.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: Ingredients is empty, please enter an ingredients.";
                    lbvalenght.Visible = true;
                    return;
                }
                //Validate for empty instruction
                if (lyric.Instructions.Length == 0)
                {
                    lbvalenght.Text = "<br>Error: Instructions is empty, please enter an instruction.";
                    lbvalenght.Visible = true;
                    return;
                }

                //lyric name maximum of 50 char allowed
                if (lyric.LyricName.Length > 50)
                {
                    lbvalenght.Text = "<br>Error: lyric Name is too long. Max of 50 characters.";
                    lbvalenght.Visible = true;
                    Name.Value = "";
                    return;
                }
                //Author name maximum of 25 char allowed
                if (lyric.Author.Length > 25)
                {
                    lbvalenght.Text = "<br>Error: Author Name is too long. Max of 25 characters.";
                    lbvalenght.Visible = true;
                    Author.Value = "";
                    return;
                }
                //Ingredients maximum of 1000 char allowed - can be increase to max of 1000 char.
                //if (lyric.Ingredients.Length > 500)
                //{
                //    lbvalenght.Text = "<br>Error: Ingredients is too long. Max of 500 characters.";
                //    lbvalenght.Visible = true;
                //    return;
                //}
                //Instruction maximum of 750 char allowed - can be increase to max of 2000 char
                //if (lyric.Instructions.Length > 750)
                //{
                //    lbvalenght.Text = "<br>Error: Instructions is too long. Max of 700 characters.";
                //    lbvalenght.Visible = true;
                //    return;
                //}
                #endregion

                if (RecipeImageFileUpload.HasFile)
                {
                    int FileSize = RecipeImageFileUpload.PostedFile.ContentLength;
                    string contentType = RecipeImageFileUpload.PostedFile.ContentType;

                    //File type validation
                    if (!contentType.Equals("image/gif") &&
                        !contentType.Equals("image/jpeg") &&
                        !contentType.Equals("image/jpg") &&
                        !contentType.Equals("image/png"))
                    {
                        lbvalenght.Text = "<br>Định dạng file không đúng. chỉ cho phép định dạng file: gif, jpg, jpeg or png.";
                        lbvalenght.Visible = true;
                        return;
                    }
                    // File size validation
                    if (FileSize > constant.RecipeImageMaxSize)
                    {
                        lbvalenght.Text = "<br>Kích thước file cho phép không quá 30000 bytes";
                        lbvalenght.Visible = true;
                        return;
                    }
                }

                ImageUploadManager.UploadRecipeImage(lyric, PlaceHolder1, GetLyricImage.ImagePathDetail, constant.RecipeImageMaxSize, false);

                if (lyric.Add(lyric) != 0)
                {
                    JSLiteral.Text = "Quá trình sử lý thất bại.";
                    return;
                }

                EmailRecipeSubmissionNotificationToAdministrator(lyric.LyricName);

                lyric = null;

                Response.Redirect("confirmaddeditlyric.aspx?mode=Added");

                Util = null;
            }
        }
    }
コード例 #4
0
    public void Add_Article(Object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            Utility Util = new Utility();

            ArticleRepository Article = new ArticleRepository();

            Article.UID = UserIdentity.UserID;
            Article.Author = UserIdentity.UserName;
            Article.Title = Util.FormatTextForInput(Request.Form["Title"]);
            Article.Summary = Util.FormatTextForInput(Request.Form["Summary"]);
            Article.Content = Request.Form["Content"];
            Article.CatID = Int32.Parse(Request.Form["ddlarticlecategory"]);
            Article.Keyword = Util.FormatTextForInput(Request.Form["Keyword"]);

            #region Form Input Validator
            if (Article.Title.Length == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Tiêu đề chưa có, Hãy nhập tiêu đề bài viết vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.CatID == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Bạn phải chọn một chuyên mục, nơi mà bài viết hiển thị";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length == 0)
            {
                lbvalenght.Text = "<br>Lõi: Nội dung tóm tắt chưa có, hãy nhập nội dung tóm tắt vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Content.Length == 0)
            {
                lbvalenght.Text = "<br>Lõi: Nội dung bài viết chưa có, hãy nhập nội dung bài viết vào.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length == 0)
            {
                lbvalenght.Text = "<br>Lỗi: Từ khóa cho bài viết chưa có, hãy nhập từ khóa vào.";
                lbvalenght.Visible = true;
                return;
            }
            //if (Article.Content.Length > 8000)
            //{
            //    lbvalenght.Text = "<br>Error: Content is too long, max of 8000 characters including HTML formatting.";
            //    lbvalenght.Visible = true;
            //    return;
            //}
            if (Article.Title.Length > 65)
            {
                lbvalenght.Text = "<br>Lỗi: Tiêu đề quá dài, nó không thể lớn hơn 65 ký tự.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Summary.Length > 350)
            {
                lbvalenght.Text = "<br>Lỗi: Nội dung tóm tắt quá dài, nó không thể vượt quá 350 ký tự.";
                lbvalenght.Visible = true;
                return;
            }
            if (Article.Keyword.Length > 80)
            {
                lbvalenght.Text = "<br>Lỗi: Từ khóa quá dài, nó không thể vượt quá 80 ký tự.";
                lbvalenght.Visible = true;
                return;
            }

            #endregion

            if (Article.Add(Article) != 0)
            {
                JSLiteral.Text = "Quá trình sử lý thất bại.";
                return;
            }

            Article = null;
            Util = null;

            Response.Redirect("confirmsubmitarticle.aspx?mode=Added");
        }
    }
コード例 #5
0
    public void Update_User(object s, EventArgs e)
    {
        Utility Util = new Utility();

        int User_ID = int.Parse(Request.QueryString["uid"]);

        if (Page.IsValid)
        {
            UserRepository User = new UserRepository();

            //Filters harmful scripts from input string.
            User.UID = User_ID;
            User.Username = username;
            User.Password = Encryption.Encrypt(Util.FormatTextForInput(Request.Form[Password1.UniqueID]));
            User.FirstName = Util.FormatTextForInput(Request.Form[Firstname.UniqueID]);
            User.LastName = Util.FormatTextForInput(Request.Form[Lastname.UniqueID]);
            User.City = Util.FormatTextForInput(Request.Form[City.UniqueID]);
            User.State = Util.FormatTextForInput(Request.Form[State.UniqueID]);
            User.Country = Util.FormatTextForInput(Request.Form[Country.UniqueID]);
            User.DOB = DateTime.Parse(Date1.CalendarDateString);
            User.FavoriteFoods1 = Util.FormatTextForInput(Request.Form[FavoriteFoods1.UniqueID]);
            User.FavoriteFoods2 = Util.FormatTextForInput(Request.Form[FavoriteFoods2.UniqueID]);
            User.FavoriteFoods3 = Util.FormatTextForInput(Request.Form[FavoriteFoods3.UniqueID]);
            User.NewsLetter = Int32.Parse(Util.FormatTextForInput(Request.Form[Newsletter.UniqueID]));
            User.ContactMe = Int32.Parse(Util.FormatTextForInput(Request.Form[ContactMe.UniqueID]));
            User.Website = Util.FormatTextForInput(Request.Form[Website.UniqueID]);
            User.AboutMe = Util.FormatTextForInput(Request.Form[AboutMe.UniqueID]);

            #region Form Input Validation

            //Check if the user update the email by comparing the current user email against the email
            //input value.If the email changed, go to the next validation.
            if (Util.FormatTextForInput(Request.Form[Email.UniqueID]) != usercurrentemail)
            {
                //Validate new email against database record. This prevent duplication.
                if (Blogic.IsEmailExists(Util.FormatTextForInput(Request.Form[Email.UniqueID])))
                {
                    lbvalenght.Text = "Error: Unable to update account. An account with the specified email already exists. Please choose another email.";
                    lbvalenght.Visible = true;
                    return;
                }
                else
                {   //If the new email does not exists, update it.
                    User.Email = Util.FormatTextForInput(Request.Form[Email.UniqueID]);
                }
            }
            else
            {
                //If the email is the same, this means it has not been change, then assign an empty string.
                //The stored procedure will do the rest of the magic.
                User.Email = "";
            }

            //Let's decrypt the password for validation.
            if (!Validator.IsAlphaNumericOnly(Encryption.Decrypt(User.Password)))
            {
                lbvalenght.Text = "<br>Error: Password must be at least 6 characters long and 12 characters maximun, and should only contain AlphaNumeric.";
                lbvalenght.Visible = true;
                return;
            }

            if (Util.FormatTextForInput(Request.Form[Password1.UniqueID]) != Util.FormatTextForInput(Request.Form[Password2.UniqueID]))
            {
                lbvalenght.Text = "<br>Error: Password did not matach. Please re-enter a password and make sure they both match.";
                lbvalenght.Visible = true;
                return;
            }

            if (!Validator.IsValidEmail(Util.FormatTextForInput(Request.Form[Email.UniqueID])))
            {
                lbvalenght.Text = "<br>Error: Invalid email address. Email address must be a valid format.";
                lbvalenght.Visible = true;
                return;
            }

            if (!Validator.IsValidName(User.FirstName))
            {
                lbvalenght.Text = "<br>Error: Firstname should be alphabet and not contain illegal characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (!Validator.IsValidName(User.LastName))
            {
                lbvalenght.Text = "<br>Error: Firstname should be alphabet and not contain illegal characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (User.FavoriteFoods1.Length > 25)
            {
                lbvalenght.Text = "<br>Error: Favorite food 1 is too long. Maximum of 25 characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (User.FavoriteFoods2.Length > 25)
            {
                lbvalenght.Text = "<br>Error: Favorite food 2 is too long. Maximum of 25 characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (User.FavoriteFoods3.Length > 25)
            {
                lbvalenght.Text = "<br>Error: Favorite food 3 is too long. Maximum of 25 characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (User.AboutMe.Length > 500)
            {
                lbvalenght.Text = "<br>Error: About me text is too long. Maximum of 500 characters.";
                lbvalenght.Visible = true;
                return;
            }

            if (User.Website.Length > 75)
            {
                lbvalenght.Text = "<br>Error: Website URL is too long. Maximum of 75 characters.";
                lbvalenght.Visible = true;
                return;
            }

            #endregion

            ImageUploadManager.UploadUserImage(User, PlaceHolder1, GetUserImage.ImagePathForUserPhotoForAdmin, 60000);

            if (User.Update(User) != 0)
            {
                JSLiteral.Text = "Error occured while processing your submit.";
                return;
            }

            Response.Redirect("confirmeditprofile.aspx");

            User = null;
        }

        Util = null;
    }
コード例 #6
0
    public void Update_User(object s, EventArgs e)
    {
        if (Authentication.IsUserAuthenticated)
        {
            Utility Util = new Utility();

            if (Page.IsValid)
            {
                UserRepository User = new UserRepository();

                //Filters harmful scripts from input string.
                User.UID = UserIdentity.UserID;
                User.Username = UserIdentity.UserName;
                User.Password = Encryption.Encrypt(Util.FormatTextForInput(Request.Form[Password1.UniqueID]));
                User.FirstName = Util.FormatTextForInput(Request.Form[Firstname.UniqueID]);
                User.LastName = Util.FormatTextForInput(Request.Form[Lastname.UniqueID]);
                User.City = Util.FormatTextForInput(Request.Form[City.UniqueID]);
                User.State = Util.FormatTextForInput(Request.Form[State.UniqueID]);
                User.Country = Util.FormatTextForInput(Request.Form[Country.UniqueID]);
                User.DOB = DateTime.Parse(Date1.CalendarDateString);
                User.FavoriteFoods1 = Util.FormatTextForInput(Request.Form[FavoriteFoods1.UniqueID]);
                User.FavoriteFoods2 = Util.FormatTextForInput(Request.Form[FavoriteFoods2.UniqueID]);
                User.FavoriteFoods3 = Util.FormatTextForInput(Request.Form[FavoriteFoods3.UniqueID]);
                User.NewsLetter = Int32.Parse(Util.FormatTextForInput(Request.Form[Newsletter.UniqueID]));
                User.ContactMe = Int32.Parse(Util.FormatTextForInput(Request.Form[ContactMe.UniqueID]));
                User.Website = Util.FormatTextForInput(Request.Form[Website.UniqueID]);
                User.AboutMe = Util.FormatTextForInput(Request.Form[AboutMe.UniqueID]);

                #region Form Input Validation

                //Check if the user update the email by comparing the current user email against the email
                //input value.If the email changed, go to the next validation.
                if (Util.FormatTextForInput(Request.Form[Email.UniqueID]) != usercurrentemail)
                {
                    //Validate new email against database record. This prevent duplication.
                    if (Blogic.IsEmailExists(Util.FormatTextForInput(Request.Form[Email.UniqueID])))
                    {
                        lbvalenght.Text = "Error: Unable to update account. An account with the specified email already exists. Please choose another email.";
                        lbvalenght.Visible = true;
                        return;
                    }
                    else
                    {   //If the new email does not exists, update it.
                        User.Email = Util.FormatTextForInput(Request.Form[Email.UniqueID]);
                    }
                }
                else
                {
                    //If the email is the same, this means it has not been change, then assign an empty string.
                    //The stored procedure will do the rest of the magic.
                    User.Email = "";
                }

                //Let's decrypt the password for validation.
                if (!Validator.IsAlphaNumericOnly(Encryption.Decrypt(User.Password)))
                {
                    lbvalenght.Text = "<br>Error: Password must be at least 6 characters long and 12 characters maximun, and should only contain AlphaNumeric.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (Util.FormatTextForInput(Request.Form[Password1.UniqueID]) != Util.FormatTextForInput(Request.Form[Password2.UniqueID]))
                {
                    lbvalenght.Text = "<br>Error: Password did not matach. Please re-enter a password and make sure they both match.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (!Validator.IsValidEmail(Util.FormatTextForInput(Request.Form[Email.UniqueID])))
                {
                    lbvalenght.Text = "<br>Error: Invalid email address. Email address must be a valid format.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (!Validator.IsValidName(User.FirstName))
                {
                    lbvalenght.Text = "<br>Error: Firstname should be alphabet and not contain illegal characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (!Validator.IsValidName(User.LastName))
                {
                    lbvalenght.Text = "<br>Error: Firstname should be alphabet and not contain illegal characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (User.FavoriteFoods1.Length > 25)
                {
                    lbvalenght.Text = "<br>Error: Favorite food 1 is too long. Maximum of 25 characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (User.FavoriteFoods2.Length > 25)
                {
                    lbvalenght.Text = "<br>Error: Favorite food 2 is too long. Maximum of 25 characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (User.FavoriteFoods3.Length > 25)
                {
                    lbvalenght.Text = "<br>Error: Favorite food 3 is too long. Maximum of 25 characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (User.AboutMe.Length > 500)
                {
                    lbvalenght.Text = "<br>Error: About me text is too long. Maximum of 500 characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                if (User.Website.Length > 75)
                {
                    lbvalenght.Text = "<br>Error: Website URL is too long. Maximum of 75 characters.";
                    lbvalenght.Visible = true;
                    return;
                }

                #endregion

                if (UserImageFileUpload.HasFile)
                {
                    int FileSize = UserImageFileUpload.PostedFile.ContentLength;
                    string contentType = UserImageFileUpload.PostedFile.ContentType;

                    //File type validation
                    if (!contentType.Equals("image/gif") &&
                        !contentType.Equals("image/jpeg") &&
                        !contentType.Equals("image/jpg") &&
                        !contentType.Equals("image/png"))
                    {
                        lbvalenght.Text = "<br>Ảnh không đúng định dạng. cho phép định dạng gif, jpg, jpeg or png.";
                        lbvalenght.Visible = true;
                        return;
                    }
                    // File size validation
                    if (FileSize > constant.UserImageMaxSize)
                    {
                        lbvalenght.Text = "<br>Kích thước vượt quá giớ hạn cho phép 60.000 byte";
                        lbvalenght.Visible = true;
                        return;

                    }
                }

                ImageUploadManager.UploadUserImage(User, PlaceHolder1, GetUserImage.ImagePathForUserPhoto, constant.UserImageMaxSize);

                if (User.Update(User) != 0)
                {
                    JSLiteral.Text = "Lỗi sảy ra trong quá trình sử lý yêu cầu của bạn.";
                    return;
                }

                string LogoutYesNo = "No";

                //Here we check if the password has been change. If the password was changed,
                //Let's logout the user.
                if (Request.Form[Password1.UniqueID] != usercurrentpassword)
                {
                    //Check if the cookies with name VGWRUserInfo exist on user's machine
                    if ((Request.Cookies["VGWRUserInfo"] != null))
                    {
                        //Expire the cookie
                        HttpCookie UserInfo = new HttpCookie("VGWRUserInfo");
                        UserInfo.Expires = DateTime.Now.AddDays(-31d);
                        Response.Cookies.Add(UserInfo);
                    }

                    //Use for session
                    if ((HttpContext.Current.Session["VGUsername"] != null) && (HttpContext.Current.Session["VGUpass"] != null))
                    {
                        HttpContext.Current.Session.Abandon();
                    }

                    LogoutYesNo = "Yes";
                }

                Response.Redirect("redirectionpage.aspx?uname=" + UserIdentity.UserName + "&uid=" + UserIdentity.UserID + "&logout=" + LogoutYesNo);

                User = null;
            }

            Util = null;
        }
    }
コード例 #7
0
    public void Add_User(object s, EventArgs e)
    {
        Utility Util = new Utility();

        if (!Page.IsValid)
        {
            UserRepository User = new UserRepository();

            User.Username = Util.FormatTextForInput(Request.Form[Username.UniqueID]);
            User.Password = Encryption.Encrypt(Util.FormatTextForInput(Request.Form[Password1.UniqueID]));
            User.Email = Util.FormatTextForInput(Request.Form[Email.UniqueID]);
            User.FirstName = Util.FormatTextForInput(Request.Form[Firstname.UniqueID]);
            User.LastName = Util.FormatTextForInput(Request.Form[Lastname.UniqueID]);
            User.City = Util.FormatTextForInput(Request.Form[City.UniqueID]);
            User.State = Util.FormatTextForInput(Request.Form[State.UniqueID]);
            User.Country = Util.FormatTextForInput(Request.Form[Country.UniqueID]);
            User.DOB = DateTime.Parse(Date1.CalendarDateString);
            User.FavoriteFoods1 = Util.FormatTextForInput(Request.Form[FavoriteFoods1.UniqueID]);
            User.FavoriteFoods2 = Util.FormatTextForInput(Request.Form[FavoriteFoods2.UniqueID]);
            User.FavoriteFoods3 = Util.FormatTextForInput(Request.Form[FavoriteFoods3.UniqueID]);
            User.NewsLetter = Int32.Parse(Util.FormatTextForInput(Request.Form[Newsletter.UniqueID]));
            User.ContactMe = Int32.Parse(Util.FormatTextForInput(Request.Form[ContactMe.UniqueID]));
            User.Website = Util.FormatTextForInput(Request.Form[Website.UniqueID]);
            User.AboutMe = Util.FormatTextForInput(Request.Form[AboutMe.UniqueID]);
            User.GUID = Guid.NewGuid().ToString("N");

            //Prevent username and email duplication. Ensure that all username and email in the database are unique.
            //This initialize the value.
            UserNameAndEmailValidation.Param(User.Username, User.Email);

            #region Form Input Validation
            //Handles validation of username and email. This prevent duplication.
            if (!UserNameAndEmailValidation.IsValid)
            {
                lbvalenght.Text = UserNameAndEmailValidation.ErrMsg;
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (!Validator.IsAlphaNumericOnly(User.Username))
            {
                lbvalenght.Text = "<br> Lỗi: Tên đăng nhập phải có ít nhất 6 ký tự và lớn nhất 15 ký tự, và chỉ nên chứa chữ số. ";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            //Let's decrypt the password for validation.
            if (!Validator.IsAlphaNumericOnly(Encryption.Decrypt(User.Password)))
            {
                lbvalenght.Text = "<br> Lỗi: Mật khẩu phải có ít nhất 6 ký tự và lớn nhất 12 ký tự, và chỉ nên chứa chữ số.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            //Let's decrypt the password for validation.
            if (Util.FormatTextForInput(Request.Form[Password1.UniqueID]) != Util.FormatTextForInput(Request.Form[Password2.UniqueID]))
            {
                lbvalenght.Text = "<br> Lỗi: Mật khẩu không giống nhau. Vui lòng. nhập một mật khẩu và đảm bảo rằng chúng phù hợp cả hai.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (!Validator.IsValidEmail(User.Email))
            {
                lbvalenght.Text = "<br> Lỗi: Địa chỉ Email không hợp lệ. Địa chỉ email. phải là một định dạng hợp lệ.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (!Validator.IsValidName(User.FirstName))
            {
                lbvalenght.Text = "<br> Lỗi: Tên của bạn nên được bảng chữ cái và không chứa các ký tự bất hợp pháp.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (!Validator.IsValidName(User.LastName))
            {
                lbvalenght.Text = "<br> Lỗi: Tên họ và tên đệm của bạn nên được bảng chữ cái và không chứa các ký tự bất hợp pháp.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.FavoriteFoods1.Length > 25)
            {
                lbvalenght.Text = "<br> Lỗi: Bài hát yêu thích 1 là quá dài, tối đa là 25 ký tự..";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.FavoriteFoods2.Length > 25)
            {
                lbvalenght.Text = "<br> Lỗi: Bài hát yêu thích 2 là quá dài, tối đa là 25 ký tự..";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.FavoriteFoods3.Length > 25)
            {
                lbvalenght.Text = "<br> Lỗi: Bài hát yêu thích 3 là quá dài, tối đa là 25 ký tự..";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.Country == "none")
            {
                lbvalenght.Text = "<br> Lỗi: Bạn phải chọn một quốc gia.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.AboutMe.Length > 500)
            {
                lbvalenght.Text = "<br> Lỗi: Văn bản giới thiệu về bản thân quá dài. tối đa là 500 ký tự.";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            if (User.Website.Length > 75)
            {
                lbvalenght.Text = "<br> Lỗi: Địa chỉ website quá dài tối đa là 75 ký tự..";
                lbvalenght.Visible = true;
                txtsecfield.Text = "";
                return;
            }

            #endregion

            if (UserImageFileUpload.HasFile)
            {
                int FileSize = UserImageFileUpload.PostedFile.ContentLength;
                string contentType = UserImageFileUpload.PostedFile.ContentType;

                //File type validation
                if (!contentType.Equals("image/gif") &&
                    !contentType.Equals("image/jpeg") &&
                    !contentType.Equals("image/jpg") &&
                    !contentType.Equals("image/png"))
                {
                    lbvalenght.Text = "<br>Ảnh của bạn không đúng định dạng. chỉ cho phép những định dạng sau gif, jpg, jpeg or png.";
                    lbvalenght.Visible = true;
                    return;
                }
                // File size validation
                if (FileSize > constant.UserImageMaxSize)
                {
                    lbvalenght.Text = "<br> Dung lượng vượt quá 60.000 byte cho phép";
                    lbvalenght.Visible = true;
                    return;

                }
            }

            ImageUploadManager.UploadUserImage(User, PlaceHolder1, GetUserImage.ImagePathForUserPhoto, constant.UserImageMaxSize);

            if (User.Add(User) != 0)
            {
                JSLiteral.Text = "Có lỗi sảy ra trong quá trình sử lý yêu cầu của bạn.";
                return;
            }

            EmailAccountActivationLink(User);

            User = null;

            Response.Redirect("redirectionpage.aspx?email=" + Request.Form[Email.UniqueID]);
        }
        else
        {
            JSLiteral.Text = Util.JSAlert("Mã bảo mật không hợp lệ. Hãy chắc chắn rằng bạn nhập chính xác.");
            return;

            lblinvalidsecode.Text = "Mã bảo mât không đúng. Hãy chắc chắn bạn đã nhập đúng các ký tự của mã bảo vệ.";
            lblinvalidsecode.Visible = true;
        }

        Util = null;
    }