protected void btnSubmit_Click(object sender, EventArgs e) { using (CSSDataContext db = new CSSDataContext()) { // If the page loaded, then don't worry about the date at this point, they'll get a free ride if // they camped on the page for a while. The date is just to keep the enemy from getting a hold // of an old email and coming back in with it. var logins = db.Logins.Where(p => p.PasswordResetGuid == new Guid(Request.Params["resetGuid"])); foreach (var login in logins) { CssMembershipProvider cssMembershipProvider = new CssMembershipProvider(); string tempPassword = cssMembershipProvider.ResetPassword(login.Username, null); cssMembershipProvider.ChangePassword(login.Username, tempPassword, txtPassword.Text); } db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, logins); foreach (var login in logins) { // Keep anyone from reusing an old password reset mail. login.PasswordResetGuid = Guid.Empty; } db.SubmitChanges(); } divResetPassword.Visible = false; divResetSuccess.Visible = true; }