1

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).

1
  • 2
    How do you authenticate the user? Are you using ASP.NET membership providers? Commented Aug 27, 2012 at 14:32

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Also, assuming that the runat attribute is set to server too!
you can just write the code as btnSave.Visible = someConditionExpressionHere. The entire if block is entirely redundant.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.