how to enable and disable button based on user role?

前端 未结 6 1850
予麋鹿
予麋鹿 2021-01-13 20:22

I have a role called \'member\' and another \'admin\' in Asp.Net website.

I did before, that button should be visible or not and i am successful in that,but,i am not

6条回答
  •  伪装坚强ぢ
    2021-01-13 21:13

    The primary problem you have here is the hash mark: <%# is used to identify a binding. Unless you're calling this in a gridview or a formview or something, this will not work. I would recommend setting it in the code behind as suggested by @Muhammad Akhtar, but if you're hell bent for leather on using the html side it should probably be:

    Enabled='<%= HttpContext.Current.User.IsInRole("Admin").ToString() %>'
    

提交回复
热议问题