I have a form with two textboxes. I am retrieving data from the database to populate the boxes. When my user clicks on submit button and the content of the 2 textboxes does not change, I dont want to go through the code.
How do I determine when the content of the boxes changes and when it does not change? Do I need to make some kind of comparison to what I have in memory?
public ActionResult Edit(profile objprofiler) { if (ModelState.IsValid) { //Go fetch the existing profile from the database var currentProfile = db.Profiles.FirstOrDefault(p => p.ProfileId == objprofiler.ProfileId); //Update the database record with the values from your model currentProfile.City = objprofiler.City; currentProfile.State = objprofiler.State; //Commit to the database! db.SaveChanges(); ViewBag.success = "Your changes have been saved"; return View(profiler); } }