I am trying to make индикатор процесса in a web application (some progressbar ).

While the file is being generated in the Controller , I want the user to see that it is being generated and he understood that the application is working. I want to make it as simple as possible. Just what would be the inscription or .gif c spinning wheel. After the file is generated, it starts loading, and before loading it is necessary to remove this indicator.

I tried to do it like this , but nothing happened .

Tell me, please, what other implementation options can there be?

For examples and tutorials - special thanks .

    1 answer 1

    You can use Ajax.BeginForm ( Primitive example here ), if it is possible to partially refresh the page without a full reload. LoadingElementId is exactly responsible for the automatic display of the indicator during the execution of the method. Just create a div with an animation element, and hide and display automatically.

    At the same time look at the appointment of other parameters. For example, OnComplete allows you to call the execution of a js-function after the execution of the query. UpdateTargetId allows you to specify the area that will be updated, replacing the previous content with the view that will be returned by the controller. I give a minimal piece of code from my project, I hope that it will be clear.

     @using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = "target", LoadingElementId = "loader" })) { /* Область, которая будет получать обновления */ <div id="target"> @Html.Partial("_Index") </div> /* Элемент-анимация загрузки */ <div id="loader" style="display:none"> <img src="@Url.Content("~/Content/Images/loading.gif")" alt="" /> Ваш запрос выполняется... </div> } 
    • Thank you so much for your help! I did it according to your example, but for some reason it does not work = ( - kxko
    • one
      @kxxko I threw a lot of things out of the code, left only the frame, so it may well be that I missed something necessary for understanding. Of course, I am not an asp.net guru, but let's try to figure it out then :) What exactly is not working? - Sleepy Panda
    • explain to me, please, why do I need here "target" =) - kxko
    • I redid a bit - it worked. Loader began to appear, but the file stopped downloading) - kxko