Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Ajax BeginForm does not page back

$
0
0

Hi,

@using (Ajax.BeginForm("CalculateWithAjaxJsonBeginForm", "Home", new AjaxOptions
{
    HttpMethod = "POST",
    OnSuccess = "SuccessMessage", // JS
    OnFailure = "FailMessage", // JS
    UpdateTargetId = "result" // p tag ID
}, new {@id = "myForm" }))
{
    @Html.TextBox("num1", null, new { @type = "number" })
    @Html.TextBox("num2", null, new { @type = "number" })<input type="submit" value="Submit form with ajax" id="btnSubmit" /><p id="result"></p>
}

 [HttpPost]
        public ActionResult CalculateWithAjaxJsonBeginForm(int num1, int num2)
        {
            ViewBag.Result = num1 + num2;
            int responseText = num1 + num2;
           // return Json(new { success = true, responseText = num1 + num2 }, JsonRequestBehavior.AllowGet);
            return Json(responseText, JsonRequestBehavior.AllowGet);
        }

I have this code which manage to come to the controller. But it does not return back to the view. Any idea what went wrong?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>