views:

20

answers:

1

Hello!

I am somewhat familar with the LoginView control and understand how to use it to create say a read-only version and edit version of one page. The page then displays different depending if you are in a "readers" role or you were granted "editors" role membership. Works nice!

Now what if for example editor1 opened the form and began updating a particular data object... I think it would be nice if all other editor role members that tried to access the same object through the page would be shown in the read only mode while editor1 still has it open. Any other object another editor opens should open in edit mode for him.

So I am thinking of messing around with the role memberships depending what object you try to display.

How would someone do something like that?

Thanks! Ralf

A: 

Hey,

That's not very easy to do, to have only one user edit a record at a time. You would have to:

  • Log in the database that a user is editing a record.
  • Use a web service to check for this status frequently.

I don't believe there is a way to make it perfect, where the user is instantly locked when another user accesses it... it will be tricky.

Alternatively, you can have a conflict resolution feature, where you can do something like compare the original values, and see if those original values changed by another user. If they did, then any changes can be merged or you can prompt the user to decide what to do, or something like that.

HTH.

Brian
Hello, thanks for your answer.I think I did not state that so clear, I do not mean to check "always" and "sniff" for changes.What I wanted to do is when editor 1 opens the form to set a marker for the object he is on, and when editor 2 then goes in to find the marker and move him to another role which in turn would handle the "can't edit" feature.It comes down to: Where in the ASP.NET page creation lifecycle can I swap the roles for the user waiting for the page? I tried a lot, from Button_click to Page_Load and even Page_PreInit... but seems that is to late for security change.
Ralf
I personally would recommend not using security for this; I would consider using a MultiView to do this. You can programmably switch between views to do what you want by setting the activeviewindex property. That would be a lot easier to do than using role-based security for this. Plus, you can do any security checks in the code-behind to ensure only the edit options appear for the right roles. As for the check, yes, basically you'll be doing a lot of updates to set that flag on and off.
Brian