student
student

Reputation: 11

hide some button in asp.net 4.0

I want to ask how can I hide some button for different users? For example, an admin can access all buttons, but a regular member cannot access some buttons (e.g. add new user button).

Upvotes: 1

Views: 163

Answers (1)

Shyju
Shyju

Reputation: 218722

Set the Visible property to true or false depending on your condition (check user),to hide or show.

  if(someConditionExpressionHere)
  {
     btnSave.Visible=true;
  }
  else
  {
    btnSave.Visible=false;
  }

Assuming btnSave is the Id of the button you want to hide/ show. You should udpdate the someConditionExpressionHere with a check to see whether the user is admin or normal user.

Upvotes: 1

Related Questions