protected void Page_Load(object sender, EventArgs e) { if (Request["submit"] != null) { string firstName = Request["firstName"]; string lastName = Request["lastName"]; string password = Request["userPassword"]; string email = Request["email"]; string id = Request["id"]; if (DataLink.IsEmailRegistered(email)) { serverResponse = string.Format("'{0}' is already registered", email); } else if (DataLink.IsIDRegistered(id)) { serverResponse = string.Format("'{0}' is already registered", id); } else { DataLink.AddUser(email, firstName, lastName, password, id); serverResponse = "User created"; AccessControl.LogIn(this, email, false); Response.Redirect("Homepage.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!AccessControl.IsLoggedIn(this)) { Response.Redirect("Homepage.aspx"); return; } DataTable user = DataLink.GetUser(AccessControl.GetLoggedUser(this)); formInputs = ContructInputs( GetFirstFromTable(user, "FirstName"), GetFirstFromTable(user, "LastName"), GetFirstFromTable(user, "ID"), GetFirstFromTable(user, "Email")); if (Request["submit"] != null) { string firstName = Request["firstName"]; string lastName = Request["lastName"]; string password = Request["userPassword"]; string email = Request["email"]; string id = Request["id"]; if (email != GetFirstFromTable(user, "Email") && DataLink.IsEmailRegistered(email)) { serverResponse = string.Format("'{0}' is already registered", email); } else if (id != GetFirstFromTable(user, "ID") && DataLink.IsIDRegistered(id)) { serverResponse = string.Format("'{0}' is already registered", id); } else { DataLink.UpdateUser(GetFirstFromTable(user, "Email"), email, firstName, lastName, password, id); AccessControl.LogIn(this, email, DataLink.IsAdmin(email)); WriteScript("alert('Data Updated')"); // If we would have used Response.Redirect, it wouldn't have loaded the alert WriteScript("window.location = 'Homepage.aspx'"); } } }