使用javascript刷新UpdatePanel时,UpdateProgress不会显示

时间:2021-08-14 21:12:31

I have an UpdatePanel and inside the update panel I have a button. The updatepanel also has an updateprogress control tied to it in order to display a loading graphic when the updatepanel does a postback.

我有一个UpdatePanel,在更新面板中我有一个按钮。 updatepanel还有一个与之关联的updateprogress控件,以便在updatepanel进行回发时显示加载图形。

If I click the button in the update panel then the progress loader shows up just fine. However, if I select the button with jQuery and do .click() the loader doesn't show up. The panel does post back and load content correctly but the progress loader doesn't trigger.

如果我单击更新面板中的按钮,则进度加载器显示正常。但是,如果我使用jQuery选择按钮并执行.click(),则加载程序不会显示。面板确实回发并正确加载内容,但进度加载程序不会触发。

Any ideas why this would be?

任何想法为什么会这样?

2 个解决方案

#1


1  

I just have tried your scenario. It works fine here.

我刚试过你的场景。它在这里工作正常。

Here is the html

这是html

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:UpdateProgress runat="server" ID="UpdateProgress1">
                <ProgressTemplate>
                    <img src="Images/ajax-loader.gif" />
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>

    <input id="btnTest" title="JQuery Click" onclick="ClickButton1()" type="button"  value="JQuery Click" />

    <script type="text/javascript">
        function ClickButton1() {     
      //  alert('#<%=Button1.ClientID %>');
        $('#<%=Button1.ClientID %>').click();
        }
    </script>

Here is the back end code to show loading image for 5 seconds

这是显示加载图像5秒的后端代码

 protected void Button1_Click(object sender, EventArgs e)
 {
    Thread.Sleep(5000);
 }

#2


0  

I never did find the answer to this question but it doesn't matter. I learned that update panels only make one request at a time for a reason. The page life-cycle and viewstate cannot be broken, therefore asynchronous requests can only be made one at a time.

我从来没有找到这个问题的答案,但没关系。我了解到更新面板出于某种原因一次只能发出一个请求。页面生命周期和视图状态不能被破坏,因此异步请求一次只能进行一次。

MVC for the win.

赢得MVC。

#1


1  

I just have tried your scenario. It works fine here.

我刚试过你的场景。它在这里工作正常。

Here is the html

这是html

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:UpdateProgress runat="server" ID="UpdateProgress1">
                <ProgressTemplate>
                    <img src="Images/ajax-loader.gif" />
                </ProgressTemplate>
            </asp:UpdateProgress>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>

    <input id="btnTest" title="JQuery Click" onclick="ClickButton1()" type="button"  value="JQuery Click" />

    <script type="text/javascript">
        function ClickButton1() {     
      //  alert('#<%=Button1.ClientID %>');
        $('#<%=Button1.ClientID %>').click();
        }
    </script>

Here is the back end code to show loading image for 5 seconds

这是显示加载图像5秒的后端代码

 protected void Button1_Click(object sender, EventArgs e)
 {
    Thread.Sleep(5000);
 }

#2


0  

I never did find the answer to this question but it doesn't matter. I learned that update panels only make one request at a time for a reason. The page life-cycle and viewstate cannot be broken, therefore asynchronous requests can only be made one at a time.

我从来没有找到这个问题的答案,但没关系。我了解到更新面板出于某种原因一次只能发出一个请求。页面生命周期和视图状态不能被破坏,因此异步请求一次只能进行一次。

MVC for the win.

赢得MVC。