How are you guys managing concurrency when using web forms. I understand that the best option is to use functional locking of sections of the application but this would be used as a general solution.
As I think about it the options I see are as follows
-
Using a timestamp column. Store timestamp (this would be either a SQL Timestamp column or date time column) value in hidden form field. When updating an entity refetch the entity use the timestamp as a predicate
-
When fetching the webform the first time store the entity in view state.
The other issue I am thinking about is how to only update the columns that the user actually changed. I think for this I can use the text changed on the input fields. For example lets say I have a FirstName and LastName text field I would do something like so
this.txt_LastName.TextChanged += new System.EventHandler(this.txt_LastName_TextChanged);
this.txt_FirstName.TextChanged += new System.EventHandler(this.txt_FirstName_TextChanged);
private void txt_LastName_TextChanged(object sender, System.EventArgs e)
{
// fetch entity from DB if null
// check and make sure timestamp is equal to local timestamp
// if timetamp checks out set field
}
I am fairly certain that this will work as the text changed events ate raised during IPostBackDataHandler.RaisePostDataChangedEvent before the click event is raised during IPostBackEventHandler.RaisePostBackEvent
Just wondering how others are doing this with web forms.
Bert