protected void UsersProfile_OnCommand(object sender, CommandEventArgs e) { switch (e.CommandName) { #region add case "add": MembershipCreateStatus status; MembershipUser user = Membership.CreateUser(LoginTxt.Text, PasswordTxt.Text, EmailTxt.Text, null, null, true, out status); if (status != MembershipCreateStatus.Success || user == null) { switch (status) { case MembershipCreateStatus.DuplicateUserName: ErrorMessageLbl.Text = "Пользователь с таким именем уже существует"; ErrorMessageLbl.Visible = true; break; case MembershipCreateStatus.DuplicateEmail: ErrorMessageLbl.Text = "Пользователь с такой почтой уже существует"; ErrorMessageLbl.Visible = true; break; default: ErrorMessageLbl.Text = "Произошла ошибка"; ErrorMessageLbl.Visible = true; break; } } else { SaveUserDetails(user.GetIdentity()); ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "popup", "closeUserDetails();", true); } break; #endregion #region update case "update": try { UserProfile profile = UserProfile.Get(Convert.ToInt32(e.CommandArgument.ToString())); SaveUserDetails(profile.UserId); ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "popup", "closeUserDetails();", true); } catch (Exception exc) { Page.StandardErrorScript(); } break; #endregion } if (Saved != null) { Saved(this, e); } }