Pergunta

Basta saber se alguém viu nenhuma barra de progresso utilizável para C # .net apps. Meu aplicativo leva cerca de 20-60 segundos para carregar e eu gostaria de mostrar aos usuários uma barra de progresso enquanto esperam. Vi esta mas o site de exemplo não parece trabalho, que doesn 't inspirar confiança.

Foi útil?

Solução

Você pode usar o AJAX UpdateProgress controle .

<asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdateProgress runat="server" id="PageUpdateProgress">
        <ProgressTemplate>
            Loading...
        </ProgressTemplate>
    </asp:UpdateProgress>
    <asp:UpdatePanel runat="server" id="Panel">
        <ContentTemplate>
            <asp:Button runat="server" id="UpdateButton" onclick="UpdateButton_Click" text="Update" />
        </ContentTemplate>
    </asp:UpdatePanel>

Se você quiser animação, tudo o que você precisa fazer é pop um .gif animado para o 'ProgressTemplate'.

Outras dicas

Gostaria de olhar para este post - parece ser uma boa maneira de fazê-lo. Eu não testei isso sozinho ...

http://mattberseth.com/blog/2008/05/aspnet_ajax_progress_bar_contr.html

Na página aspx você precisa escrever isso, eu adicionei certa classe CSS que você mesmo precisa definir, functinality sábio este código irá ajudá-lo

<asp:Panel ID="ProgressIndicatorPanel" runat="server" Style="display: none" CssClass="modalPopup">
        <div id="ProgressDiv" class="progressStyle">
            <ul class="ProgressStyleTable" style="list-style:none;height:60px">
                <li style="position:static;float:left;margin-top:0.5em;margin-left:0.5em">
                    <asp:Image ID="ProgressImage" runat="server" SkinID="ProgressImage" />
                </li>
                <li style="position:static;float:left;margin-top:0.5em;margin-left:0.5em;margin-right:0.5em">
                    <span id="ProgressTextTableCell"> Loading, please wait... </span>
                </li>
            </ul>
        </div>
    </asp:Panel>

Defina um ProgressIndicator função digamos assim

var ProgressIndicator = function (progPrefix) {
    var divId = 'ProgressDiv';
    var textId = 'ProgressTextTableCell';
    var progressCss = "progressStyle";

    if (progPrefix != null) {
        divId = progPrefix + divId;
        textId = progPrefix + textId;
    }

    this.Start = function (textString) {
        if (textString) {
            $('#' + textId).text(textString);
        }
        else {
            $('#' + textId).text('Loading, please wait...');
        }
        this.Center();
        //$('#' + divId).show();
        var modalPopupBehavior = $find('ProgressModalPopupBehaviour');
        if (modalPopupBehavior != null) modalPopupBehavior.show();
    }

    this.Center = function () {
        var viewportWidth = jQuery(window).width();
        var viewportHeight = jQuery(window).height();
        var progressDiv = $("#" + divId);
        var elWidth = progressDiv.width();
        var elHeight = progressDiv.height();
        progressDiv.css({ top: ((viewportHeight / 2) - (elHeight / 2)) + $(window).scrollTop(),
            left: ((viewportWidth / 2) - (elWidth / 2)) + $(window).scrollLeft(), visibility: 'visible'
        });
    }

    this.Stop = function () {
        //$("#" + divId).hide();
        var modalPopupBehavior = $find('ProgressModalPopupBehaviour');
        if (modalPopupBehavior != null) modalPopupBehavior.hide();
    }
};

O exemplo dado conatins um indicador de progresso com Modal, i:. E quando o progresso indicador está em execução ele desabilita outras operações a serem realizadas no screen.You pode remover a parte Modal se does not precisam

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top