edit the Buttons edit --> update button

edit the Buttons edit --> update button

Godrules500Godrules500 Posts: 25Questions: 13Answers: 0
edited September 2016 in Free community support

Hello, I am trying to use buttons, but I have something interesting that I am needing to do. I want to keep the functionality of the edit button meaning I want it to pop up the same modal. I even want them to hit update the same way. However, I want to intercept it after they hit update. I am needing to get the values so that I can run some calculations after they hit update. Is this possible?

Answers

  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    If you just want to modify the data submitted to the server use preSubmit.

    Allan

  • Godrules500Godrules500 Posts: 25Questions: 13Answers: 0

    Ah. I didn't know that existed. In the code below, is there anyway to do it before new Editor() is called? That way I can do it from the controller level?

      [AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
        public ActionResult LoadAdministrators() 
        {
            //var settings = Properties.Settings.Default; 
            var formData = HttpContext.Request.Form;
            using (var ctx = new OldCastle001())
            {
                var test = ctx.administrators.ToList();
                using (var db = new Database("sqlserver", ctx.Database.Connection))
                {
                    var response = new Editor(db, "administrators", "administratorsid")
                    .Model<administrator>() 
                    .Process(formData)
                    .Data();
                    test = ctx.administrators.ToList();
                    return Json(response, JsonRequestBehavior.AllowGet);
                }
            }
        }
    
  • allanallan Posts: 63,815Questions: 1Answers: 10,517 Site admin

    The code you have pasted above is C#, while the event I linked to above is a Javascript event. You would need to use the preSubmit event in your Javascript. That will modify the data before it is submitted to your C# controller.

    Allan

This discussion has been closed.