I used article Role based Authorization and Authentication in ASP.Net which hide shows menu based on role in Forms Authentication. if you are not using Form Authentication then just write code to get the role value from database based on user and do same type code as per your code logic.
Contact.aspx
<h1>
Contact</h1>
<asp:Button ID="btnDelete" runat="server" Text="Delete" />
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// Here i am checking from role based using Form Authentication
// If you are not using Form Authentication then just get the role value from database and implement same logic for your functionality.
btnDelete.Visible = this.Page.User.IsInRole("Administrator");
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
btnDelete.Visible = Me.Page.User.IsInRole("Administrator")
End If
End Sub
Screenshot
