CANT GET INPUT PARAMETER TO CONTROLLER, AJAX.ACTIONLINK

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 5638  View(s)
Ratings:
Rate this:
Hi Everyone!

<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
    <script src="../../Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
    @Ajax.ActionLink("Save", "Index", "Home", new AjaxOptions { UpdateTargetId = "saveResult" }, new { id = "1001" })
    <div id="saveResult">
</div>

Controller

public ActionResult Index(string id)
        {
            return View();
        }

Thank in advance!
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Cant get input parameter to controller, Ajax.ActionLink

    Hi Jaden!

    You are calling "UpdateTargetId" before passing parameter, that wrong way

    Relpace your Ajax.ActionLink from below

    @Ajax.ActionLink("Save", "Index", "Home", new { id = "1001" }, new AjaxOptions { UpdateTargetId = "saveResult" })

    I hope it resolve your problem.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!