0

I want to add an animation when I click on the "Link" button before the result of my controller is displayed.

.cshtml:

 @Ajax.ActionLink("associer ?", "Associer", "Ressources", new { IdUtilisateur = item.UtilisateurSuggere.IdUtilisateur, IdUnite = item.IdUnite },
new AjaxOptions
{
    HttpMethod = "Post",
    LoadingElementId = "div_loading_" + item.IdUnite, // Image GIF DIV
    LoadingElementDuration = 1000,
    UpdateTargetId = "ajaxtarget_" + item.IdUnite, // Result DIV
    InsertionMode = InsertionMode.Replace
})

.cs :

public  string Associer(int? IdUtilisateur, int? IdUnite){
Utilisateur new_u = db.Utilisateurs.Find(IdUtilisateur);
return new_u.Prenom + " " + new_u.Nom;}

Actually the result appears along with the image.

Thank you.

  • I see your Function Associer is not ActionResult in controller. Your code never work – Linh Tuan May 17 '16 at 15:26
  • Take a look at this link: http://stackoverflow.com/questions/1964839/how-can-i-create-a-please-wait-loading-animation-using-jquery. I used it in the past and it worked very well - simple implementation, too. It also covers all ajax requests from your website in one fell swoop. – Nick May 17 '16 at 15:33
  • Linh Tuan the result is a string not an ActionResult ! Nicholas Thanks It's not exactly what I want to do but it's a start. – Nicolas Antoine May 20 '16 at 10:04

0 Answers0