2
나는 DisabledControl이라는 사용자 컨트롤이 있습니다. 이 두 가지 조건으로 if 문을 생성해야합니다. OwnerOnly
가 void
를 반환하는 방법이기 때문에여러 사용자 조건에 따라 활성화 된 버튼
public static class DisabledControl
{
public static void AdminOnly(this Control control)
{
control.Enabled = User.IsInRole(new string[] { "Administrator" });
}
public static void OwnerOnly(this Control control, int ownerID)
{
control.Enabled = (User.ID == ownerID);
}
}
//I need help with syntax: if User isinRole 'Adminstrator" && user is OwnerOnly, btnSave.Enabled=true.
//I tried to use if user.id == OwnerOnly, it gives error.
나는 어느 쪽이든 도움이 필요합니다 : 귀하의 의견에 응답
는 이런 일을하려고합니다. –
@Gina 당신이 무엇을 요구하고 있는지 잘 모르겠습니다. 'Enabled' 속성을 토글하는 확장 메소드를 작성했습니다. 당신은 다른 방법을 추가하여 Admin || 소유자. –
다음과 같이 구분할 수 있습니다. btnSave.AdminOnly(); and btnSaved.OwnerOnly (int) InvestigatorCase.CreatedBy();하지만 사용자가 OwnerOnly && AdminOnly 인 경우 buttonSave.enabled = true가 필요합니다. 나를 표시하는 다른 방법이 있습니까? –