Hello all, I'm building an application where I'll have three kind of roles for the users: viewers, superusers and administrators. On the left side of each page I have a menu with several items. What is the best approach to make my application to draw different
menu items based on roles? For instance the Edit Order or Delete Order menu item shouldn't be available to viewers but to superusers and administrators. Moreover, I would like to use this approach for the content of the HTML files. For example, from a search
page I go to a page showing a datatgrid with the results found. I want that superuser and administrators to see for each item in the result the data and two links: a link for edit and one for delete links that shouldn't be available to the viewer. An idea
will be highly appreciated, TIA Max
There are lots of ways to do this so I can't say that this is THE best way, but it is how I would do it. I would recommend that you create a new base class for your pages, lets call it RolePage. Then in the constructor or Init for that class you determine the
role of the user and set a protected property to be the role. Then in your derived pages, you just have to check that property and render the HTML accordingly. You can break this up into different methods for each role, aka Page_LoadSuperUser, Page_LoadAdmin,
etc. or you can put the switches directly into your methods. I think the methods version is probably cleaner. Hope this helps,
maxtech
Member
30 Points
6 Posts
Best method to show different content based on roles
Sep 15, 2003 10:40 AM|LINK
fpaulb
Member
190 Points
38 Posts
Re: Best method to show different content based on roles
Sep 15, 2003 02:19 PM|LINK
Looking into .Net? We can help!
The Rochester Consulting Partnership, Inc.
http://www.Rochester-Consulting.com