ASP.NET:在 UpdatePanel 中使用回发​​时禁用所有控件 - 类似于 ajas 动画?

发布于 2024-10-03 22:28:53 字数 228 浏览 3 评论 0原文

我正在使用 UpdatePanel,并且需要在使用 UpdatePanel 刷新页面时显示某种 Ajax 动画。

最好的是能够禁用所有控件并显示 ajax 加载消息。

我很乐意在所有内容的顶部放置一个 Div - 就像覆盖层一样。 Jquery UI 对话框的作用几乎相同。

有人有这方面的经验吗?

问题是用户在从回发(使用更新面板)返回之前单击项目,

提前致谢

I am using the UpdatePanel and need to display some kind of Ajax anination while the page refreshes with the UpdatePanel.

What would be great is to be able to disable all controls and display a ajax loading message..

I would love to put a Div over the top of everything - like an overlay. Jquery UI dialog box does pretty much the same.

Does anyone have any experience with this?

Problem is that users are click items before returning from a PostBack (using the update panel)

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南风几经秋 2024-10-10 22:28:53

我也遇到了同样的问题,并且很幸运地偶然发现了 UpdateProgress MSDN 上的控件概述。该页面上的示例显示了用于挂钩 ASP UpdatePanel 控件的异步 ajax 调用的秘密 javascript。经过一点修改,我就可以让 jQuery BlockUI 插件 正常工作使用 ASP UpdatePanel。

这就是我最终得到的结果。这里应该有足够的内容,以便您可以在异步回调开始和结束时做任何您想做的事情。

HTML

<asp:UpdateProgress runat="server" id="updateProgress1" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="false" DisplayAfter="0">
    <ProgressTemplate>Processing...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <!-- Some stuff here -->
    </ContentTemplate>
</asp:UpdatePanel>

JAVASCRIPT

$(document).ready(function () {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);
    function InitializeRequest(sender, args) {
        // Whatever you want to happen when the async callback starts
        $.blockUI();
    }
    function EndRequest(sender, args) {
        // Whatever you want to happen when async callback ends
        $.unblockUI();
    }
});

请注意,我包含了一个 ASP UpdateProgress 控件,这很重要,因为如果没有该控件,JavaScript 将无法正常工作。它会阻塞和解除阻塞 UI,但解除阻塞部分不会在回调返回时发生,它几乎在异步调用启动后立即发生。

I too was struggling with this same issue and was lucky enough to stumble across the UpdateProgress Control Overview on MSDN. An example on that page shows secret javascript for hooking into the async ajax calls of the ASP UpdatePanel control. With a little modification I was able to get the jQuery BlockUI plugin to work with an ASP UpdatePanel.

Here is what I ended up with. There should be enough here so that you could do anything you want when the async callback begins and when it ends.

HTML

<asp:UpdateProgress runat="server" id="updateProgress1" AssociatedUpdatePanelID="UpdatePanel1" DynamicLayout="false" DisplayAfter="0">
    <ProgressTemplate>Processing...</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <!-- Some stuff here -->
    </ContentTemplate>
</asp:UpdatePanel>

JAVASCRIPT

$(document).ready(function () {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);
    function InitializeRequest(sender, args) {
        // Whatever you want to happen when the async callback starts
        $.blockUI();
    }
    function EndRequest(sender, args) {
        // Whatever you want to happen when async callback ends
        $.unblockUI();
    }
});

Notice that I included an ASP UpdateProgress control, that is important because if you don't have that, the javascript doesn't work right. It will block and unblock the UI but the unblock part does not happen when the callback returns, it happens almost immediately after the async call is started.

似狗非友 2024-10-10 22:28:53

对我来说,阻止控件本身 DropDownList 而不是整个 UI 就足够了,我所做的一切都不是使用 jquery.blockUI() 插件,我只是添加了一行,它对我来说工作得很好

这是我添加的内容:

$('#DD_selectPassportType').attr('disabled', 'disabled');

@InitializationRequest

function InitializeRequest(sender, args) {

    // Whatever you want to happen when the async callback starts
    $('#DropDownList_ID').attr('disabled', 'disabled');
}
function EndRequest(sender, args) {
    // Whatever you want to happen when async callback ends
    nothing I did in here
}

It was sufficient for me to block the control itself DropDownList instead of the entire UI and all I did instead of using jquery.blockUI() plugin I just added one line and it worked just fine for me

Here is what I did add :

$('#DD_selectPassportType').attr('disabled', 'disabled');

@ the InitializationRequest

function InitializeRequest(sender, args) {

    // Whatever you want to happen when the async callback starts
    $('#DropDownList_ID').attr('disabled', 'disabled');
}
function EndRequest(sender, args) {
    // Whatever you want to happen when async callback ends
    nothing I did in here
}
ζ澈沫 2024-10-10 22:28:53

可以使用ajax控制工具包的Update进度控制。当页面引用更新面板时,将显示下图,并且用户无法单击页面项目。

<ajax:UpdateProgress AssociatedUpdatePanelID="UpdatePanel3" ID="updateProgress3"                 runat="server">
<ProgressTemplate>
 <div>
  <img alt="Loading" src="images/Adding.gif" />
 </div>
</ProgressTemplate>
</ajax:UpdateProgress>

这里UpdatePanel3是你的更新面板的id。

您还可以添加ajaxcontrol工具包的AlwaysVisibleControlExtender。

<cc1:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender3" runat="server"
                TargetControlID="updateProgress3" VerticalSide="Middle" HorizontalSide="Center"
                VerticalOffset="10" HorizontalOffset="10" ScrollEffectDuration=".1">
            </cc1:AlwaysVisibleControlExtender>

这里cc1是ajax控制工具包dll的标签前缀。

You can use Update progress control of ajax control tool kit. when page refersh with update panel then below image will be show and user can not click on page items.

<ajax:UpdateProgress AssociatedUpdatePanelID="UpdatePanel3" ID="updateProgress3"                 runat="server">
<ProgressTemplate>
 <div>
  <img alt="Loading" src="images/Adding.gif" />
 </div>
</ProgressTemplate>
</ajax:UpdateProgress>

Here UpdatePanel3 is id of your update panel.

You can also add AlwaysVisibleControlExtender of ajaxcontrol tool kit.

<cc1:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender3" runat="server"
                TargetControlID="updateProgress3" VerticalSide="Middle" HorizontalSide="Center"
                VerticalOffset="10" HorizontalOffset="10" ScrollEffectDuration=".1">
            </cc1:AlwaysVisibleControlExtender>

Here cc1 is tag prefix of ajax control tool kit dll.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文