Reputation: 30293
In asp.net ajax, is there any control that indicate the user, wait processing is going on ?. i have to display any animation.
protected void Button1_Click(object sender, EventArgs e)
{
//Thread.Sleep(1500);
string sqr = "select * from Pra_Region";
da = new SqlDataAdapter(sqr, con);
ds = new DataSet();
da.Fill(ds);
grdProduct.Visible = true;
grdProduct.DataSource = ds;
grdProduct.DataBind();
}
Upvotes: 0
Views: 109
Reputation: 19217
You can use the UpdateProgress
control to achieve this. You can show anything inside the UpdateProgess
container when any AJAX postback
occurs. Look at the example below:
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Thread.Sleep(200);
tt.InnerText = DateTime.Now.ToShortTimeString();
grid.DataSource = new List<object>
{
new {Name = "Munim", Age = 2, Time = DateTime.Now.ToShortTimeString()},
new {Name = "Rashim", Age = 3, Time = DateTime.Now.ToShortTimeString()},
new {Name = "Robin", Age = 25, Time = DateTime.Now.ToShortTimeString()}
};
grid.DataBind();
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="sm">
</asp:ScriptManager>
<div>
<asp:UpdatePanel runat="server" ID="UpdPnl1" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataGrid runat="server" ID="grid"></asp:DataGrid>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="click" />
<div id="tt" runat="server">
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="updQuoteProgress" runat="server" AssociatedUpdatePanelID="UpdPnl1"
DisplayAfter="0">
<ProgressTemplate>
Loading...</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
Use the table in your DataSet
protected void Button1_Click(object sender, EventArgs e)
{
//Thread.Sleep(1500);
string sqr = "select * from Pra_Region";
da = new SqlDataAdapter(sqr, con);
ds = new DataSet();
da.Fill(ds);
grdProduct.Visible = true;
grdProduct.DataSource = ds.Tables[0];
grdProduct.DataBind();
}
Upvotes: 2