So I have some information I show a user about their account. However, an administrator can see this page, and decide to click "Activate" or "Deactivate" on a user.
Expected behavior: If the administrator presses Activate on an inactive account, the information queries the database and displays at the top that the user's account is active. And the success message is displayed.
The current behavior: If the administrator presses Activate on an inactive account, the information doesn't requery, it still says the user's account is INACTIVE. And the success message is displayed.
I'm using OnClick and runat="server" on the buttons. And the information table that queries the database is in Page_Load(). I'm not using the "IsPostBack" or anything, so it should refresh the information.
Do I have to put a "Reload()" or "Refresh()" or "DataBind()" type function at the end of my "btnUpdate_OnClick(object sender, EventArgs e)" function? How would I do this?
I just don't understand why the event lifecycle won't just reload the page completely.
EDIT:
Some simplified code:
protected void Page_Load(object sender, EventArgs e)
{
if (Request["uid"] != null)
userID = Int32.Parse(Request["uid"]);
UserDAO ud = new UserDAO();
tblUser u = ud.GetUser(userID);
AccountStatus.Text = (((Boolean)u.ActiveOrNot) ? "Active" : "Inactive") + "<br />";
}
protected void btnActivate_OnClick(object sender, EventArgs e)
{
UserDAO udao = new UserDAO();
int userBeingEdited = -1;
if (Request["uid"] != null)
{
userBeingEdited = Int32.Parse(Request["uid"]);
}
if (udao.ActivateUser(userBeingEdited))
{
DisplayError("This user has been activated.", true);
}
}
Where AccountStats is a Asp:label. And GetUser queries the database.
That's all the relevant code.
I'm wondering why Onclick doesn't refresh the page and reload Page_Load() function!!