【问题标题】:Is there any way to update bootstrap progress bar width from aspx.cs?有没有办法从 aspx.cs 更新引导进度条宽度?
【发布时间】:2020-07-16 13:44:19
【问题描述】:

我有一个按钮可以打开引导程序的模式弹出窗口。在 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.net twitter-bootstrap-3 webforms


    【解决方案1】:

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

    【讨论】:

    • 谢谢。对于 ajax 调用,我必须正确设置 [WebMethod],我必须将我的 btn_click 转换为 Web 服务
    • 基本上是的,有不止一种实现方式,具体如何由您决定,但最终您的 btn_click 代码将被移动到不同的页面或 Web 方法,您可以使用 ajax 调用.
    • 谢谢你,我希望这会有所帮助
    猜你喜欢
    • 2014-01-18
    • 1970-01-01
    • 1970-01-01
    • 2011-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 2010-11-16
    相关资源
    最近更新 更多