UpdateProgress不适用于触发器属性内部的按钮

Sin*_*lan 4 asp.net updatepanel updateprogress

     <asp:UpdatePanel ID="Upnl1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
      <table width="100%"><tr>
                            <td align="center" colspan="3">
                                <asp:Button ID="btnShowReport" runat="server" CssClass="ButtonClassLong" SkinID="LargeButton"
                                    Text="Show Report" OnClick="btnShowReport_Click"   TabIndex="15" />
                                <asp:Button ID="btnClear" runat="server" CssClass="ButtonClass" Text="Clear" OnClick="btn_Click"
                                    TabIndex="16" />
                                <asp:Button ID="btnClose" runat="server" CssClass="ButtonClass" OnClick="btnClose_Click"
                                    Text="Close" CausesValidation="False" TabIndex="17" />
                                <asp:CheckBox ID="ChkPrint" Text="Print View" runat="server" TabIndex="14" />
                            </td>
                        </tr>
                    </table></ContentTemplate>
<Triggers>
     <asp:PostBackTrigger ControlID="btnShowReport" />
</Triggers></asp:UpdatePanel><asp:UpdateProgress ID="UpdateProgress" runat="server">
            <ProgressTemplate>
                <asp:Image ID="Image1" ImageUrl="~/App_Themes/RIBO/Images/Progress.gif" AlternateText="Processing"
                    runat="server" />
            </ProgressTemplate>
        </asp:UpdateProgress>
Run Code Online (Sandbox Code Playgroud)

这是我的编码,我的问题是当我点击清除按钮时更新进度运行良好,当我点击btnShowReport它不会工作.

如何显示触发器属性内的按钮单击事件的更新进度.

May*_*hak 5

问题是AssociatedUpdatePanelID.你没有为你的'UpdateProgress`设置Associateid

设置它 UpdateProgress

<asp:UpdateProgress ID="UpdateProgress" runat="server"  AssociatedUpdatePanelID="Upnl1">
Run Code Online (Sandbox Code Playgroud)

根据MSDN

UpdateProgress控件呈现显示或隐藏的元素,具体取决于关联的UpdatePanel控件是否导致异步回发.对于初始页面呈现和同步回发,不显示UpdateProgress控件.

编辑:

原因是 <asp:PostBackTrigger ControlID="btnShowReport" />

这将导致整页回发.你应该改变你Trigger

<asp:AsyncPostBackTrigger ControlID="btnShowReport" />
Run Code Online (Sandbox Code Playgroud)

它会为你完成工作......如果你能阅读引用的陈述,你也可以自己解决它......