Activating loading animation by Html.BeginForm submission

前端 未结 2 1207
挽巷
挽巷 2021-02-05 16:42

I want to display loading animation when the user clicks on submit button. Simple gif will do the job. This is my code:

@using (Html.BeginForm(\"SData\",\"Crawl\         


        
2条回答
  •  自闭症患者
    2021-02-05 17:21

    Hello I just read your post here and it worked fine for me in .net core 2.1 using Microsoft.AspNetCore.Mvc:

    @using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new {id="UpdateForm"})) {@Html.AntiForgeryToken()

    your inputs here...
    }

    then the HTML script:

    $("#UpdateForm").submit(function(e){$("#your loader gif here..")}

    if you have problems you might want to debug your Action Method and see if it breaks inside the statement.... @Dr Freeman: you are able to redirect to any view as follows:

    return RedirectToAction("ActionName", new {@id=id});

    Hope this help

提交回复
热议问题