Issue
I have a delete button on a repeater
which is in update panel
. When i click the delete button
, it can delete, but It takes about 10 seconds. So I want to add a loading gif
. I am beginner on adding gif
. Please help me. Thanks for interests
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:NET2ConnectionString %>' SelectCommand="SELECT * FROM [ProductsRA]"></asp:SqlDataSource>
<asp:Repeater ID="rptuser" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="rpr1_ItemCommand" OnItemDataBound="rpr1_ItemDataBound">
<ItemTemplate>
<tr>
<td class="GridItems">
<asp:ImageButton runat="server" ID="delbtn" ImageUrl="~/images/delete.gif" CommandName="Delete" CommandArgument='<%# Eval("ID") %>' ValidationGroup="ab" ToolTip="Delete User" /></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"ID") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"ProductName") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Quantity") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"UnitPrice") %></td>
<td class="GridItems">
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rptuser" />
</Triggers>
</asp:UpdatePanel>
this is cs:
protected void rpr1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
DataSet.ProductsRADataTable dt = new DataSet.ProductsRADataTable();
DataSetTableAdapters.ProductsRATableAdapter adp = new DataSetTableAdapters.ProductsRATableAdapter();
if (e.CommandName == "Delete")
{
adp.DeleteQuery(Convert.ToInt32(e.CommandArgument));
}
}
Solution
You can use UpdateProgess control for this.
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="loading_div">
<p>Please wait while we process the request.</p>
<img src="/Images/loader.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Use an overlay div if you want to block the page while processing the request.
.loading_div {
position: absolute;
color:#fff;
background-color: #000;
z-index: 2000 !important;
opacity: 0.6;
overflow: hidden;
text-align: center;
top: 0;
left: 0;
height: 100%;
width: 100%;
padding-top:20%;
}
It will render like this while the request is processed: http://jsfiddle.net/codeandcloud/jLmbmLmn/
Answered By - naveen Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.