kumar shivam
kumar shivam

Reputation: 69

How to disable a button based on the role of logged in user in ASP .net

I have following role in my application, User, Visitor and Admin. In my application i want to give access for delete button to User and Admin and not to User in ASP .net. How would i implement this functionality?

Upvotes: 0

Views: 426

Answers (1)

VDWWD
VDWWD

Reputation: 35514

You can use IsInRole

if (User.IsInRole("Admin") || User.IsInRole("User"))
{
    Button1.Enabled = true;
}
else
{
    Button1.Enabled = false;
}

Upvotes: 1

Related Questions