[RESOLVED]HTTP get to HTTP post how to transfer value

I am new to MVC and ASP.net

I have a property called CurrentProcessStatus in class called PRF

public string CurrentProcessStatus {get; set;}

which I am using in Razor view I want to use as Dropdown which will show 7-8 different processes from which one the PRF object will be in one process in given time.

Whenever this CurrentProcessStatus dropdown is changed I want to record the datetime and it’s original value before user modified to make it’s history using the following class.

public class ProcessHistory
        public int ProcessHistoryId { get; set; }
        public string ProcessName { get; set; }
        public DateTime ProcessDate { get; set; }
        public int ProcessNumber { get; set; }
        public int Delay { get; set; }


The problem I am facing value of the property is overwritten whenever user changes it with HTTP post.

I am stuck on how to implement this, I don’t know what and how to use please assist me.


It would seem easier to just record the new value and the current datetime in the history whenever a change is done. In your case :
- the current value is not part of the history
- in the history you have on a row a value and the date/time on which it was overriden by the next value

In my case:
- the current value is part of the history
- in the history I have on a row the value and the date/time on which it took effect

If you still prefer the former way, the object you get back is the one that is posted so you do have the posted (changed) values. If you want to get the previous value you would have to use an hidden field or to read back the database (or for example to
use a trigger to handle this history feature).

Double check it’s not just easier to just register each new value and the current date in the history…

use a hidden variable in your in your razor review to have the old value of the CurrentProcessStatus.

and then access it in your Post method.

@Html.HiddenFor(model => model.ProcessId)

in your httppost method, you are passing a parameter of your form. the value of your selectedid will be part of your form object. return the view with that model and you should be fine.

assuming you are submitting the data to the server, return redirectToAction("View") of your original form and fetch the new data.

Leave a Reply