Donate

Ajax.ActionLink() Not Redirecting To ActionResult With Ajax Attribute

Given that I have this code in my .cshtml page using Ajax.ActionLink() that calls a controller method using Ajax request:
@Ajax.ActionLink("Select", "TaskListing", new { id = item.TaskID }, 
   new AjaxOptions(){ 
    HttpMethod = "GET",
    UpdateTargetId = "taskListing",
    InsertionMode = InsertionMode.Replace
})
And the controller method called by the Ajax ActionLink is decorated with Ajax attribute.
[HttpGet]
[AjaxOnly(true)]
[ActionName("TaskListing")]
public ActionResult TaskListing_Ajax(int id = -1)
{
 var projects = projRep.GetAllProjects();
 var model = new TaskAndTaskViewModel();
 model.Task = te.Tasks.FirstOrDefault(t => t.TaskID == id);
 model.SelectList = from p in projRep.GetAllProjects()
        select new SelectListItem
        {
         Selected = (p.ProjectID == Convert.ToInt32(model.Task.ProjectID)),
         Text = p.ProjectName.ToString(),
         Value = p.ProjectID.ToString()
        };

 return PartialView("TaskForm", model);
}
Normally, the request would push through. If does not proceed, maybe you have not added the Microsoft JQuery Unobtrusive Ajax to your project. Downloading and installing the said package(Microsoft JQuery Unobtrusive Ajax) via NuGet might fix the problem.

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.