加载页面时,带有 UpdatePanel 的 UpdateProgress 未显示在用户控件中

发布于 2024-07-13 08:49:33 字数 920 浏览 6 评论 0原文

这是 ASP.Net UpdatePanel 的 UpdateProgress 的典型行为吗? 我在页面上的用户控件窗口内有一个带有 UpdateProgress 控件的更新面板。

如果我让页面在后台进行一些加载并单击用户控件更新面板中的按钮,则 UpdateProgress 根本不会显示。 就像 UpdatePanels 刷新请求甚至没有注册,直到实际页面完成其业务之后。 值得注意的是,如果后台没有发生任何事情,它就会显示出来。

我想要的功能正是您所期望的。 我希望加载程序在单击按钮后显示是否必须等待任何事情才能完成刷新。

我知道如果我只将 jquery ajax 与静态 Web 方法一起使用,我可以获得此功能,但用户控件内不能有静态 Web 方法。 我可以将它放在页面中,但它确实不属于那里。 在这种情况下,成熟的 wcf 也不值得。 我试图与 UpdatePanel 妥协,但这些事情似乎总是给我带来一些麻烦。

也许这就是它的工作原理?

编辑:所以我会澄清一下我在做什么。

发生的情况是我有一个页面,上面只有一些侧面的工具和一张大地图。 当页面最初加载时,需要一些时间来加载地图。 现在,如果在加载时我打开其中包含有问题的更新面板的工具(用户控件),然后单击该用户控件上的按钮,该按钮应使用新数据刷新更新面板并显示加载标志(在 updateprogress 中) )然后 UpdateProgress 加载图像不会显示。 但是,通过单击按钮运行的代码确实会在页面加载完成后运行(如预期),并且如果包含用户控件的页面上没有任何内容正在加载,则将显示 UpdateProgress。

我只想在页面加载时显示加载程序。

我认为我的问题是地图加载可能在更新面板中,而我的 UpdateProgress 仅与用户控件的更新面板的更新面板相关联。 因此,加载地图时我不会看到加载图标。 但事实并非如此。

Is this typical behavior of the UpdateProgress for an ASP.Net UpdatePanel? I have an update panel with the UpdateProgress control inside of a user control window on a page.

If I then make the page in the background do some loading and click a button in the user control update panel the UpdateProgress does not show up at all. It's like the UpdatePanels refresh request is not even registered until after the actual page is done doing it's business. It's worth noting that it will show up if nothing is happening in the background.

The functionality I want is what you would expect. I want to loader to show up if it has to wait for anything to get it's refresh done when after the button is clicked.

I know I can get this functionality if I just use jquery ajax with a static web method, but you can't have static web methods inside of a user control. I could have it in the page but it really doesn't belong there. A full-blown wcf wouldn't really be worth it in this case either. I'm trying to compromise with an UpdatePanel but these things always seem to cause me some kind of trouble.

Maybe this is just the way it works?

Edit:So I'll clarify a bit what I'm doing.

What's happening is I have a page and all it has on it are some tools on the side and a big map. When the page initially loads it takes some time to load the map. Now if while it's loading I open up the tool (a user control) that has the update panel in question in it and click the button on this user control that should refresh the update panel with new data and show the loading sign (in the updateprogress) then the UpdateProgress loading image does not show up. However, the code run by the button click does run after the page is done loading (as expected) and The UpdateProgress will show up if nothing on the page containing the user control is loading.

I just want the loader to show up while the page is loading.

I thought my problem was that perhaps the map loading is in an update panel and my UpdateProgress was only being associated with the update panel for the user control's update panel. Hence, I would get no loading icon when the map was loading. This is not the case though.

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

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

发布评论

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

评论(2

情栀口红 2024-07-20 08:49:33

我没有完全遵循您在这里所做的事情,但我假设您已经获取了用户控件中的内容并验证了如果直接放置在页面中它是否可以正常工作?

附带说明一下,我个人正在放弃 UpdatePanels 并用 jQuery 替代品进行替换,因为它可以显着节省性能,而且了解 jQuery 等更省时。 怪癖而不是 ASP.NET AJAX 怪癖。 老实说,我希望能够收回在 UpdatePanels/ASP.NET AJAX 上投入的时间。

I'm not completely following exactly what you're doing here, but I'm assuming you've taken what's in your user control and verified that it works correctly if placed directly in the page?

As a side note, I'm personally ripping out UpdatePanels and replacing with jQuery replacements due to the significant performance savings in addition to the fact that it's way more time-effective to figuring out jQuery et al. quirks instead of ASP.NET AJAX quirks. To be honest, I wish I could claw back the time I did invest in UpdatePanels/ASP.NET AJAX.

﹏半生如梦愿梦如真 2024-07-20 08:49:33

相信在多次阅读您的OP后我理解了您的问题。 我自己也遇到过这种情况,很难让 UpdateProgress 在 Page_Load 上工作。 解决方案? 最初不要在 Page_Load 上触发服务器端事件。 添加位于 UpdatePanel 内的 AJAX 计时器,如下所示:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
     <asp:Timer ID="ajxTmr1" runat="server" Interval="1000" OnTick="ajxTmr1_Tick" />
  </ContentTemplate>
</asp:UpdatePanel>

在计时器滴答事件上,根据需要执行服务器代码。 如果您将更新进度连接到上面的更新面板,则一切都应该正常工作。

<asp:UpdateProgress ID="UpdateProgress1"  runat="server" DisplayAfter="0"  AssociatedUpdatePanelID="UpdatePanel1" Visible="false">
    <%--Panel or whatever goes here--%>
</asp:UpdateProgress>

I believe I understand your issue after reading your OP several times. I have run into this situation myself with difficulty getting an UpdateProgress to work on Page_Load. The solution? Don't fire the server-side event initially on Page_Load. Add an AJAX Timer that is inside an UpdatePanel like below:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  <ContentTemplate>
     <asp:Timer ID="ajxTmr1" runat="server" Interval="1000" OnTick="ajxTmr1_Tick" />
  </ContentTemplate>
</asp:UpdatePanel>

The on the timer tick event, do your server code as required. If you have an Update Progress wired up to the UpdatePanel above, everything should work properly.

<asp:UpdateProgress ID="UpdateProgress1"  runat="server" DisplayAfter="0"  AssociatedUpdatePanelID="UpdatePanel1" Visible="false">
    <%--Panel or whatever goes here--%>
</asp:UpdateProgress>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文