我在 ProcessButton
事件 Click 上的页面中使用了 updateProgress
栏,但它在所有与另一个控件事件相关的回发中始终可见这一页。
当我单击 cancel
按钮时,它将可见。在 textbox
的 textchanged
事件中,它将可见。我想看到 updateProgress
将仅在我的 BtnProcess
Click 事件上起作用。我有另一个用于明文框的 button
。还在这个页面上使用更新 Pane 和 ajax 控件。
如何解决我的问题。在此页面中,我给了 Post true 一个文本框
<div class="container-fluid">
<div class="row-fluid">
<div class="well span5 center login-box">
<div class="alert alert-info">
<font size="4"><b></b></font></div>
<form id="form1" runat="server">
<fieldset>
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1"
runat="server">
</ajaxToolkit:ToolkitScriptManager>
<asp:UpdatePanel ID="pan1" runat="server">
<ContentTemplate>
<table style="width: 100%">
<tr>
<td align="left" colspan="2" class="style16">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1" DisplayAfter="10" runat="server" AssociatedUpdatePanelID="pan1">
<ProgressTemplate>
<div class="divWaiting">
<asp:Label ID="lblWait" runat="server" Text=" Your Data Is Processing... " />
<asp:Image ID="imgWait" runat="server" ImageAlign="Middle" ImageUrl="~/Processing/progress.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate></asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="right" class="style18">
Date</td>
<td align="left" class="style3">
<div class="input-prepend" title="Select Date" data-rel="tooltip">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtDate" runat="server" AutoPostBack="True"
ontextchanged="txtDate_TextChanged"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1"
runat="server" Format="dd/MM/yyyy" TargetControlID="txtDate">
</ajaxToolkit:CalendarExtender>
</ContentTemplate></asp:UpdatePanel>
</div>
</td>
</tr>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnProcess" class="btn-primary" runat="server" Text="Attendance Process" Height="36px" Width="133px" onclick="btnProcess_Click" />   
<asp:Button ID="btnclear" class="btn-primary" runat="server" Text="Clear" Height="36px" Width="91px"
onclick="btnclear_Click" />
<asp:Label ID="lblmsg" runat="server" ForeColor="Red"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td align="left" colspan="2" style3">
  
<%-- <div class="alert alert-info">
<font="4"><b>Processing Report.</b></font>
</div>--%>
<asp:GridView ID="GridView1" style="margin-left:170px;" runat="server" BackColor="#DEBA84"
BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"
CellSpacing="2" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" PageSize="5"
onpageindexchanging="GridView1_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="SL.No">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:BoundField DataField="ProcDate" HeaderText="ProcDate"
SortExpression="ProcDate" ReadOnly="True" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" />
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
</asp:GridView>
</td>
</tr>
<tr>
<td align="left" style3" class="style19">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ManjilasConnectionString %>"
SelectCommand="select Convert(varchar(10),ProcDate,126)As ProcDate,Status from ProcessingDate order by ProcDate desc"></asp:SqlDataSource>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnProcess" />
</Triggers><%----%>
</asp:UpdatePanel>
</div>
</i></span>
</fieldset>
</form>
</div>
</div><!--/span-->
</div>
最佳答案
使用此代码更新 codebehind
文件:
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterAsyncPostBackControl(this.btnProcess);
关于c# - 如何仅为按钮事件设置进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31429457/