/// <summary> /// Handles the CreatingUser event of the RegisterUser control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.LoginCancelEventArgs"/> instance containing the event data.</param> protected void RegisterUser_CreatingUser(object sender, LoginCancelEventArgs e) { App_Code.Controls.RecaptchaControl captcha = (App_Code.Controls.RecaptchaControl)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("recaptcha") as App_Code.Controls.RecaptchaControl; if (Membership.GetUser(this.RegisterUser.UserName) != null) { e.Cancel = true; this.Master.SetStatus("warning", Resources.labels.anotherUserName); } else if (Membership.GetUserNameByEmail(this.RegisterUser.Email) != null) { e.Cancel = true; this.Master.SetStatus("warning", Resources.labels.anotherEmail); } else if (captcha != null) { captcha.Validate(); if (!captcha.IsValid) { e.Cancel = true; this.Master.SetStatus("warning", "Captcha invalid."); } } }
string CreateNewBlog() { string message = string.Empty; Blog blog = null; if (!BlogGenerator.ValidateProperties(BlogName.Text, UserName.Text, Email.Text, out message)) { if (string.IsNullOrWhiteSpace(message)) { message = "Validation for new blog failed."; } return(message); } // recaptcha check SetCaptcha(Form.Controls); if (captcha != null) { captcha.Validate(); if (!captcha.IsValid) { message = "Captcha invalid."; return(message); } } blog = BlogGenerator.CreateNewBlog(BlogName.Text, UserName.Text, Email.Text, Password.Text, out message); if (blog == null || !string.IsNullOrWhiteSpace(message)) { return(message ?? "Failed to create the new blog."); } return(message); }