c# - 有没有办法从 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);
但问题是模式弹出窗口在此调用期间关闭?
解决方案
回发到 .cs 页面的性质是页面不可避免地被刷新,这将重置您的 javascript,包括弹出窗口。如果您想在服务器上执行操作时避免刷新,您需要使用 AJAX 通过 javascript 向服务器发出请求,而不是让页面进行回发。
推荐阅读
- python - 使用 keras 或 tensorflow 训练具有一个输出的 cnn,具有两个单独的数据集,每个数据集对应的损失函数
- java - '警告 BG8102:X 类具有未知的基本类型 Y' 警告,同时在 xamarin 中绑定 java 代码
- azure - Azure Keyvault 可供各种订阅中的服务主体访问
- javascript - HTML 按钮仅适用于网页重新/加载
- c# - 如何制作可以返回结果或未经授权的 ASP.NET Web API 控制器方法?
- algorithm - 这个 BFS 算法的时间复杂度是多少?
- r - 如何在交互图中显示标准化 y 分数
- python-3.x - 如何用集合填充数组
- mysql - laravel [1049] 未知数据库
- android - Android - Changing Gradle.properties according to flavor