Show loader on Ajax.BeginForm submit

后端 未结 1 1501
野的像风
野的像风 2021-02-20 03:57

What is the best way to show a loader and disable the button when we submit a form:

@using (Ajax.BeginForm(MVC.Account.Login(), new AjaxOptions { OnSuccess = \"o         


        
1条回答
  •  轮回少年
    2021-02-20 04:45

    Put your loading image tag inside a div tag like this:

    In your CSS file:

    div#loading { display: none; }
    

    And, in your form:

    @using (Ajax.BeginForm(MVC.Account.Login(), 
      new AjaxOptions { OnSuccess = "onLoginSuccess", LoadingElementId = "loading", 
        OnBegin = "onLoginBegin" }, 
      new { @id = "loginForm" }))
    {
      

    @HeelpResources.AccountLoginViewLoginButtonLabel

    }

    And, add a script to your View:

    
    

    0 讨论(0)
提交回复
热议问题