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

时间:2022-08-24 17:41:34

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.

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

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.

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

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.

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

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.

发生的事情是我有一个页面,它的所有内容都是侧面的一些工具和一张大地图。页面最初加载时需要一些时间来加载地图。现在,如果在加载时我打开了包含相关更新面板的工具(用户控件)并单击此用户控件上的按钮,该按钮应使用新数据刷新更新面板并显示加载符号(在updateprogress中) )然后UpdateProgress加载图像不会显示。但是,按钮单击运行的代码在页面加载完成后运行(如预期的那样),如果正在加载包含用户控件的页面上没有任何内容,则UpdateProgress将显示。

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.

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

2 个解决方案

#1


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.

作为旁注,我个人正在扯掉UpdatePanels并取代jQuery替换,因为除了实现jQuery等更方便的时间之外,还可以显着节省性能。怪癖而不是ASP.NET AJAX怪癖。说实话,我希望能够回到我投资UpdatePanels / ASP.NET AJAX的时候。

#2


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:

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

<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.

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

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

#1


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.

作为旁注,我个人正在扯掉UpdatePanels并取代jQuery替换,因为除了实现jQuery等更方便的时间之外,还可以显着节省性能。怪癖而不是ASP.NET AJAX怪癖。说实话,我希望能够回到我投资UpdatePanels / ASP.NET AJAX的时候。

#2


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:

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

<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.

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

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