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 able to get the proper code(aspx.cs) to disable the button so that it may be in view but not at all accessible.
<asp:Button ID="Button4" runat="server" PostBackUrl="~/report.aspx"
Text="print in report format" Width="173px"
Enabled='<%# HttpContext.Current.User.IsInRole("Admin") %>' />
i want that whenever a member login then button "report" should be disabled for him.
You have to set the Button.Enabled
property value to according to the HttpContext.Current.User.IsInRole("admin")
function returned value.
Either in html:
<Button ... Enabled='<%# HttpContext.Current.User.IsInRole("Admin") %>' ... >
Or in code behind:
Button.Enabled = HttpContext.Current.User.IsInRole("Admin");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With