简体   繁体   English

第二次单击同一按钮时未出现UpdateProgress

[英]UpdateProgress not appearing on second click of same button

UpdateProgress appear first time, when i click on the button btnSubmit. 当我单击按钮btnSubmit时,UpdateProgress第一次出现。 But when i click the same button next time UpdateProgress not appearing. 但是当我下次单击同一按钮时,UpdateProgress不会出现。 But all other things works well. 但是所有其他事情都运作良好。 I am using this UpdateProgress to show a GIF image while sending E-mail to client. 我正在使用此UpdateProgress在将电子邮件发送给客户端时显示GIF图像。 For the first client UpdateProgress appear but for second to other 'n' UpdateProgress not appearing. 对于第一个客户端,UpdateProgress出现,而对于第二个客户端,n而不显示UpdateProgress。 Please help i am asking this question Second time in Stack Overflow 请帮助我问这个问题第二次在堆栈溢出

Code below shows my UpdateProgress 下面的代码显示了我的UpdateProgress

 <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <asp:UpdateProgress ID="updProgress"
                runat="server">
                <ProgressTemplate>
                    <div class="modal">
                        <div class="center">
                            <span style="padding-left: 10px"><b>Please Wait..</b></span>
                            <img alt="" src="../images/Preloader_3.gif" width="50" height="50" />
                        </div>
                    </div>
                </ProgressTemplate>
            </asp:UpdateProgress>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

Code below shows my button that trigger the UpdateProgress 下面的代码显示了触发UpdateProgress的我的按钮

 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
    </Triggers>
    <ContentTemplate>
    <div class="form-group row">
        <div class="col-sm-6">
            <div class="col-sm-6">
                <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click"
                    OnClientClick="javascript:return btnSubmit();" CssClass="btn btn-primary"
                    runat="server" Text="Submit" />
                <a href="assignment.aspx?sid=<%=Request.QueryString["sid"] %>" class="btn btn-default">Cancel</a>
            </div>
        </div>
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>

Code Behind CS CS背后的代码

 protected void btnSubmit_Click(object sender, EventArgs e)
    {
        updProgress.Visible = true;
        SendEmail(Convert.ToInt32(drpDiv.Text));
        updProgress.Visible = false;
    }

You have to place your update progress outside the update panel and associate with update progress. 您必须将更新进度放置在更新面板之外,并与更新进度相关联。 You can create another update panel to trigger your button with auto post back true. 您可以创建另一个更新面板,以使用自动回发true触发按钮。

<asp:UpdateProgress ID="UpdateProgress1" runat="server" 
                    AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
    <!-- Place your Message here -->
</ProgressTemplate>
</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" runat="server" 
                    AutoPostBack="true" />
    </ContentTemplate>
</asp:UpdatePanel>

<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
    <!-- You can put some controls here -->
</ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

Or, second method is: 或者,第二种方法是:

<asp:UpdateProgress ID="UpdateProgress1" runat="server" 
                    AssociatedUpdatePanelID="UpdatePanel1">
    <ProgressTemplate>
        <!-- Place your Message here -->
    </ProgressTemplate>
</asp:UpdateProgress>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" runat="server" 
                    AutoPostBack="true" />
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM