For my project multiple users could edit the same item at the same, but I want to implement something which will grant a first user to be able to edit the record, but as long as that user is working on the item which is related to that particular record
I want it to be locked so that when a second user tries to edit the item he'll get a popup saying the item is locked and that he'll have to wait.
First I was thinking I could do this by saving the record "Locked=True" when the first user opens the item and it gets unlocked when they save and exit the item, but of course there's the chance they just happen to close the browser. How would I catch this
event?
The modifications to an item won't be a quick edit of one field, but a lot of work and a lot of child records will be linked to this one item so now I'm thinking of forcing the users to actually save & exit. In case they didn't they could see a list of items
which are locked by them and offer them the chance to release an item. Next to this an admin could release items that are locked by anyone.
Thanks for your reply, but did you read my full post?
I don't think I'll need to handle concurrency like that if I do it the way I mentionned in my post, but I'm wondering what experience people have with this.
To be honest,I'm afraid it's hard to control with that……because no one knows at which time who will begin to enter here to begin his/her first edition of the specific row,and because HTML is of no memoryable……So hard to control with server-side directly。
Yannick86
Member
565 Points
366 Posts
Locking a record
Feb 15, 2012 11:20 AM|LINK
Dear,
For my project multiple users could edit the same item at the same, but I want to implement something which will grant a first user to be able to edit the record, but as long as that user is working on the item which is related to that particular record I want it to be locked so that when a second user tries to edit the item he'll get a popup saying the item is locked and that he'll have to wait.
First I was thinking I could do this by saving the record "Locked=True" when the first user opens the item and it gets unlocked when they save and exit the item, but of course there's the chance they just happen to close the browser. How would I catch this event?
The modifications to an item won't be a quick edit of one field, but a lot of work and a lot of child records will be linked to this one item so now I'm thinking of forcing the users to actually save & exit. In case they didn't they could see a list of items which are locked by them and offer them the chance to release an item. Next to this an admin could release items that are locked by anyone.
What do you guys think?
Thanks in advance,
- Yannick
tdykstra
Contributor
4475 Points
625 Posts
Microsoft
Moderator
Re: Locking a record
Feb 15, 2012 04:29 PM|LINK
The way you handle concurrency depends on the database access technology you are using. If you are using Entity Framework, see this tutorial:
http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application
It also explains some of the disadvantages of the locking approach you are thinking about.
Yannick86
Member
565 Points
366 Posts
Re: Locking a record
Feb 16, 2012 08:33 AM|LINK
Heya,
Thanks for your reply, but did you read my full post?
I don't think I'll need to handle concurrency like that if I do it the way I mentionned in my post, but I'm wondering what experience people have with this.
Thanks,
- Yannick
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Locking a record
Feb 17, 2012 01:29 AM|LINK
Hello Yannick86:)
To be honest,I'm afraid it's hard to control with that……because no one knows at which time who will begin to enter here to begin his/her first edition of the specific row,and because HTML is of no memoryable……So hard to control with server-side directly。
Maybe(If you are using DataSource,you can see this:Each record can be editted by one person:http://www.asp.net/web-forms/tutorials/data-access/accessing-the-database-directly-from-an-aspnet-page/implementing-optimistic-concurrency-with-the-sqldatasource-vb,this seems like what you are asking……)