首页 > 解决方案 > 有没有办法从 aspx.cs 更新引导进度条宽度?

问题描述

我有一个按钮,可以打开引导程序的模式弹出窗口。在 Modal Pop 中,我使用引导进度条显示用户操作的进度。

<asp:LinkButton CssClass="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#exampleModal" runat="server">
                CSV Upload <i class="fas fa-file-upload"></i>
            </asp:LinkButton>
            <UC:UCBulkUpload ID="ucBulkUpload" runat="server"></UC:UCBulkUpload>

在 aspx.cs 页面中执行上传操作后,我已将进度更新为 100%,我在脚本标记内的同一页面的 javascript 中有代码。

在此处输入图像描述

function endprogress() {
        document.getElementById('uploadprogress').classList.remove("w-50");
        document.getElementById('uploadprogress').classList.add("w-75");
        setTimeout(() => {
            document.getElementById('uploadprogress').classList.remove("w-75");
            document.getElementById('uploadprogress').classList.add("w-100");
            document.getElementById('uploadprogress').innerHTML = "Upload Finished.";
        }, 500);
    }

我正在使用后面的代码调用 javascript fn

ScriptManager.RegisterStartupScript(this, GetType(), "endprogress", "endprogress();", false);

但问题是模式弹出窗口在此调用期间关闭?

标签: c#asp.nettwitter-bootstrap-3webforms

解决方案


回发到 .cs 页面的性质是页面不可避免地被刷新,这将重置您的 javascript,包括弹出窗口。如果您想在服务器上执行操作时避免刷新,您需要使用 AJAX 通过 javascript 向服务器发出请求,而不是让页面进行回发。


推荐阅读