简体   繁体   中英

How do I hide a login button when user is logged in?

I am working on website that redirect the user to the same page when he log out and I am trying to hide login button and the username and password text boxes when the user is logging in and show the user name and the logout button only and vise versa,

I tried but when I click log in button it still show log in button with username and password text boxes, and it should hide them and show user name and log out button only, I used .visible = false as shown below:

if session["userName"] == NULL)
{
login_btn.visible = true;
logout_btn.visible = false;
}  
login_btn.visible = false;
logout_btn.visible = true;

I solved this issue I just needed to add else in this code:

if session["userName"] == NULL)
{
login_btn.visible = true;
logout_btn.visible = false;
}
else // this solved the issue
{
login_btn.visible = false;
logout_btn.visible = true;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM