protected void Page_Load(object sender, EventArgs e) { //Check if the page has already been run for the first or second time if (!IsPostBack) { //Get the users ID int ID = Convert.ToInt32(Session["LoggedInUserID"]); //Check if the users logged in before editing if (ID != 0) { //Get the users information User user = SC.getUser(ID); //Checks if the user exists if (user != null) { //Assign the inputs to the users original data first_Name.Value = user.User_FirstName; Surname.Value = user.User_Surname; Email.Value = user.User_Email; Username.Value = user.User_Name; Password.Value = user.User_Password; Cellphone.Value = user.User_Cellphone; Address.Value = user.User_Address; } //If the user does not exist else { //Security purposes in case someone tried to change their session ID errorUpdate.Visible = true; } } else { //If users not logged in notify the user and Redirect the user to the login or register page errorSignin.Visible = true; Response.Redirect("SignIn.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { Session["LoggedInUserID"] = "4"; if (Session["LoggedInUserID"] != null) { User CurrentUser = SC.getUser(Int32.Parse(Session["LoggedInUserID"].ToString())); if (CurrentUser.USer_Type.Equals("Admin")) { AdminOnly.Visible = true; } else { AdminOnly.Visible = false; } } else { AdminOnly.Visible = false; } }