How to allow read-only for a certain type of user?

Asked

Viewed 439 times

1

I have a button that triggers an event to close a school year. By clicking this button, the person can have access to all the screens of the system, but can not edit anything, delete, insert. Is there any way to block only these functions for the user not to have to validate screen by screen system?

  • Complicated to say details without knowing your system.

  • But there is some way to do a "general" validation without having to validate screen by screen?

  • This part of the validation is unclear. Is it a user interface problem? User can’t change screen because it doesn’t give enough data filled, and gives validation error? Is that it? The question is very vague, please use the [Edit] link below it and try to include more relevant information.

  • @Stonesour Your system is ASP.NET MVC?

  • No, let’s assume the following: I have a boot that closes the school year, after it closes nothing else can be done, such as launching grades, exclusion of subjects, these things. Validation for this I know how to do, I just wonder if there is a way for me to validate this generally, without having to go on screen by screen and check if the year has been closed...

  • Its system is MVC5 ?

  • No, I don’t use MVC.

  • Since you are not using ASP.NET MVC, it could indicate which technology you are using?

  • Oops, I licked the tags, sorry!

Show 4 more comments

2 answers

3

I would do something like that (ASP.NET MVC in Razor + jQuery):

@section scripts {
    @if (User.IsInRole("Diretores")) {
        <script>
            $(document).ready(function() {
                $("input, select, textarea").attr("disabled", "disabled");
            });
        </script>
    }
}

0


If you are using Windows Forms, in Form you can declare a global variable called Tipousuario and then create a method to do the check and if the Form type is not the administrator change the Enable property of each Form.

  • good, I’m using Webform, but that’s how I did it, after logging in I check if the month has already been closed and assign to a Session, and I made a class that enable false arrow for all components of the page, but this does not prevent me from touching all screens to do the check, but at least the work is minor, just call the validation method in Pageload. Thank you.

  • have a doubt, I step enable = false for all button components of my page, however, when this button is in a Panel I can not set false for it, there would be another way?

  • If it is possible to show your code it will be easier to understand the problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.