Update Progress on processing after fileupload

好久不见. 提交于 2019-12-24 02:09:37

问题


I have a webform with two upload controls and a number of textfields. When the button is pressed the files get uploaded and then get processed. The upload takes no time, but the processing does. I know I can't have an upload control in an update panel, so I can't work out how to use the update progress control to show my progress.

My page with an updateprogress control that does work is as follows:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="true">
            <ProgressTemplate>
                <div class="LOADING">
                    Your data is being processed<br />
                    <br />
                    <img src="/images/loading.gif" /><br />
                    <br />
                    Please wait...
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <div class="addFixture">
            <asp:ValidationSummary ID="ValidationSummary1" ValidationGroup="fixture" runat="server" />
            <label>
                Type
                <asp:DropDownList ID="ddlType" runat="server" AppendDataBoundItems="true">
                    <asp:ListItem Text=""></asp:ListItem>
                </asp:DropDownList>
                <label>
                    Date
                </label>
                <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
                <label>
                    Name 1</label>
                <asp:TextBox ID="txtName1" runat="server"></asp:TextBox>
                <label>
                    Name 2
                    <asp:TextBox ID="txtName2" runat="server"></asp:TextBox>
                    <label>
                        First XML File</label>
                    <asp:FileUpload ID="firstFileUp" runat="server" />
                    <br />
                    <label>
                        Second Xml File</label>
                    <asp:FileUpload ID="secondFileUp" runat="server" />
                    <br />
                    <br />
                    <asp:Button ID="SubmitButton"  runat="server" CausesValidation="true" Text="Submit" OnClick="SubmitButton_Click" />
                    <asp:Label ID="ErrorMessageLabel" runat="server" EnableTheming="false"></asp:Label>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

I have searched for this, but people seem to be trying to get the progress of the file upload and not the processing.

Can anyone help?


回答1:


Remove the UpdatePanel as all the way you can't use FileUpload controls inside it. Add to the SubmitButton OnClientClick property with following value: OnClientClick="showProgress()" Also add onto the page javascript function below:

function showProgress() {
     var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
     updateProgress.style.display = "block";
}

By the way, consider to use some async file upload control like one from the Ajax Control Toolkit library




回答2:


You can use an UpdatePanel and the FileUpload if you use the ASyncFileUploadControl. It works pretty well. Make sure you download the latest version because there were a couple of issues with prior releases.



来源:https://stackoverflow.com/questions/7585140/update-progress-on-processing-after-fileupload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!